IndentingWriter extends Writer { public void printSignedLongAsDec(long value) throws IOException { int bufferIndex = 23; if (value < 0) { value *= -1; write('-'); } do { long digit = value % 10; buffer[bufferIndex--] = (char)(digit + '0'); value = value / 10; } while (value != 0); bufferIndex++; writeLine(buffer, bufferIndex, 24-bufferIndex); } IndentingWriter(Writer writer); @Override void write(int chr); @Override void write(char[] chars); @Override void write(char[] chars, int start, int len); @Override void write(String s); @Override void write(String str, int start, int len); @Override Writer append(CharSequence charSequence); @Override Writer append(CharSequence charSequence, int start, int len); @Override Writer append(char c); @Override void flush(); @Override void close(); void indent(int indentAmount); void deindent(int indentAmount); void printUnsignedLongAsHex(long value); void printSignedLongAsDec(long value); void printSignedIntAsDec(int value); void printUnsignedIntAsDec(int value);  }
@Test public void testPrintSignedLongAsDec() throws IOException { StringWriter stringWriter = new StringWriter(); IndentingWriter writer = new IndentingWriter(stringWriter); writer.printUnsignedIntAsDec(-1); writer.close(); Assert.assertEquals("4294967295", stringWriter.toString()); }