### Question:
StringUtility { @Deprecated public static String splitAndIndent(String str, int indent, int numChars) { final int inputLength = str.length(); boolean perfectFit = (inputLength % numChars == 0); int fullLines = (inputLength / numChars); int formatLength = perfectFit ? (indent + 1) * fullLines : (indent + 1) * (fullLines + 1); int outputLength = inputLength + formatLength; StringBuilder sb = new StringBuilder(outputLength); for (int offset = 0; offset < inputLength; offset += numChars) { SpaceCharacters.indent(indent, sb); sb.append(str, offset, Math.min(offset + numChars,inputLength)); sb.append('\n'); } return sb.toString(); } StringUtility(); static String prettyPrint(String in, int lineLength, String delim); @Deprecated static String splitAndIndent(String str, int indent, int numChars); static void splitAndIndent(String str, int indent,
            int numChars, PrintWriter writer); static String byteArraytoHexString(byte[] array); static byte[] hexStringtoByteArray(String str); static void main(String[] args);  }### Answer:
@SuppressWarnings("deprecation") @Test public void testSplitAndIndexToString() { String src = "abcdef"; String expected = " abcd\n ef\n"; assertEquals(expected, StringUtility.splitAndIndent(src, 2, 4)); expected = " a\n b\n c\n d\n e\n f\n"; assertEquals(expected, StringUtility.splitAndIndent(src, 1, 1)); expected = " " + src + "\n"; assertEquals(expected, StringUtility.splitAndIndent(src, 1, src.length())); }
@Test public void testSplitAndIndexToWriter() { String src = "abcdef"; String expected = " abcd\n ef\n"; StringWriter out = new StringWriter(); StringUtility.splitAndIndent(src, 2, 4,new PrintWriter(out)); assertEquals(expected, out.toString()); expected = " a\n b\n c\n d\n e\n f\n"; out = new StringWriter(); StringUtility.splitAndIndent(src, 1, 1,new PrintWriter(out)); assertEquals(expected, out.toString()); expected = " " + src + "\n"; out = new StringWriter(); StringUtility.splitAndIndent(src, 1, src.length(),new PrintWriter(out)); assertEquals(expected, out.toString()); }