### Question:
HexPrinter { public HexPrinter append( byte value ) { checkNewLine(); addHexValue( value ); return this; } HexPrinter( PrintStream out );  HexPrinter( PrintStream out, int bytesPerGroup, String groupSep ); HexPrinter withBytesPerLine( int bytesPerLine ); HexPrinter withBytesPerGroup( int bytesPerGroup ); HexPrinter withGroupSeparator( String separator ); HexPrinter withLineNumberDigits( int maxLineNumberDigits ); HexPrinter withLineNumberPrefix( String prefix ); HexPrinter withLineNumberSuffix( String suffix ); HexPrinter withLineNumberOffset( long offset ); HexPrinter withByteSeparator( String byteSeparator ); HexPrinter withBytesGroupingFormat( int bytesPerLine, int bytesPerGroup, String separator ); HexPrinter withLineNumberFormat( int maxLineNumberDigits, String prefix, String suffix ); HexPrinter append( byte value ); HexPrinter append( ReadableByteChannel source ); HexPrinter append( ReadableByteChannel source, int atMost ); HexPrinter append( ByteBuffer bytes, int offset, int length ); HexPrinter append( ByteBuffer bytes ); HexPrinter append( byte[] bytes ); static String hex( ByteBuffer bytes, int offset, int length ); static String hex( ByteBuffer bytes, int offset, int length, int bytesPerBlock, String groupSep ); static String hex( ByteBuffer bytes ); static String hex( ByteBuffer bytes, int bytesPerBlock, String groupSep  ); static String hex( byte[] bytes ); static String hex( byte[] bytes, int bytesPerBlock, String groupSep ); static String hex( byte b );  }### Answer:
@Test public void shouldPrintACoupleOfLines() { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream( outStream ); HexPrinter printer = new HexPrinter( out ); for ( byte value = 0; value < 40; value++ ) { printer.append( value ); } out.flush(); assertEquals( format( "00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F " + "10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F%n" + "20 21 22 23 24 25 26 27" ), outStream.toString() ); }