private String roundtrip( final String msg, final boolean ensure ) throws IOException { final ByteArrayInputStream baos = new ByteArrayInputStream( msg.getBytes( "UTF-8" ) ); final UnixLineEndingInputStream lf = new UnixLineEndingInputStream( baos, ensure ); final byte[] buf = new byte[100]; final int read = lf.read( buf ); lf.close(); return new String( buf, 0, read, "UTF-8" ); }