7677787980818283848586
ByteArrayOutputStream os = new ByteArrayOutputStream(); TapOutputStream tos = new TapOutputStream(os); tos.write(65); tos.write(66); assertEquals("AB", tos.asString()); assertEquals("AB", new String(os.toByteArray())); } @Test
8889909192939495969798
ByteArrayOutputStream os = new ByteArrayOutputStream(); TapOutputStream tos = new TapOutputStream(os); tos.write("ABC".getBytes()); assertEquals("ABC", tos.asString()); assertEquals("ABC", new String(os.toByteArray())); } @Test
100101102103104105106107108
ByteArrayOutputStream os = new ByteArrayOutputStream(); TapOutputStream tos = new TapOutputStream(os); tos.write("ABCD".getBytes(), 1, 2); assertEquals("BC", tos.asString()); assertEquals("BC", new String(os.toByteArray())); } }