### Question:
StreamUtility { public static String enc(String in) { if (in == null || in.isEmpty()) { return ""; } StringBuilder out = new StringBuilder(); enc(in, out); return out.toString(); }  static String enc(String in); static void enc(String in, StringBuilder out); static void enc(String in, PrintStream out); static void enc(String in, Writer out); static void enc(char[] in, int start, int length, StringBuffer out); static void enc(char[] in, int start, int length, StringBuilder out); static void enc(char[] in, int start, int length, Writer out); static void enc(char in, StringBuffer out); static void enc(char in, StringBuilder out); static void enc(char in, PrintStream out); static void enc(char in, Writer out); static void pipeStream(InputStream in, OutputStream out, int bufSize); static byte[] getBytes(InputStream in); static InputStream getStream(String string);  }### Answer:
@Test public void testEncoding() { String in = "\"foo"; String expected = "&quot;foo"; String actual = StreamUtility.enc(in); assertEquals(expected, actual); in = "foo\""; expected = "foo&quot;"; actual = StreamUtility.enc(in); assertEquals(expected, actual); in = "&<foo>'\""; expected = "&amp;&lt;foo&gt;&apos;&quot;"; actual = StreamUtility.enc(in); assertEquals(expected, actual); in = "foo bar"; expected = in; actual = StreamUtility.enc(in); assertEquals(expected, actual); }