TextUtil { public static String formatTextBox(String text, int width) { requireNonNull(text); return formatTextBox(text, width, WORDS, Collections.emptySet()); } private  TextUtil(); static Stream<String> wordsOf(String text); static String formatTextBox(String text, int width); static String formatTextBox(String text, int width, Pattern splitter, Set<String> singleRowers); static String formatJavaDocBox(String text); static String alignCenter(String substring, int totalWidth); static String alignCenter(String substring, int totalWidth, char fill); static String alignLeft(String substring, int totalWidth); static String alignLeft(String substring, int totalWidth, char fill); static String alignRight(String substring, int totalWidth); static String alignRight(String substring, int totalWidth, char fill);  }
@Test void testFormatTextBox() { String text = "A AB ABC AB Abc ad skh sjh ajsh a aksjka ka sdja aVeryLongWordThatCertainlyWillOverflow bye"; int width = 10; String tenChars = " "; String expResult = "A AB ABC\n" + "AB Abc ad\n" + "skh sjh\n" + "ajsh a\n" + "aksjka ka\n" + "sdja\n" + "aVeryLongWordThatCertainlyWillOverflow\n" + "bye"; final String result = TextUtil.formatTextBox(text, width); assertEquals(expResult, result); }