StreamUtil { public static String getUTF8OutputStreamAsString(ByteArrayOutputStream baos) { try { return baos.toString(StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException uee) { throw new RuntimeException(uee); } }  static String getUTF8OutputStreamAsString(ByteArrayOutputStream baos);  }
@Test public void testGetUTF8OutputStreamAsString() throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byteArrayOutputStream.write("test".getBytes(StandardCharsets.UTF_8.name())); String utF8OutputStreamAsString = StreamUtil.getUTF8OutputStreamAsString(byteArrayOutputStream); assertEquals("test", utF8OutputStreamAsString); }