StringUtils { public static int wrappedLinesEstimate(String text, int colWidth) { List<String> lines = toStringLines(text); int estimate = 0; for (String s : lines) { int wrapEstimate = (int) Math.ceil(s.length() / colWidth); if (wrapEstimate == 0) { estimate++; } else { estimate += wrapEstimate; } } return estimate; } private  StringUtils(); static Pair pair(String left, String right); static String truncate(String s, int length, boolean addDots); static String trimToEmpty(String s); static String trimToNull(String s); static String repeat(char c, int count); static String join(Object[] a, char delimiter); static String join(Collection<String> c, char delimiter); static List<String> split(String s, char delimiter, boolean skipBackSlash); static boolean isBlank(String s); static String toIdString(String name); static StringUtils.Pair splitByFirstLineFeed(String text); static List<String> toStringLines(String text); static int countLineFeeds(String text); static int wrappedLinesEstimate(String text, int colWidth); static boolean isJavaScriptFunction(String text); static String fixJavaScriptFunction(String text);  }
@Test public void testWrappedLinesEstimate() { assertEquals(6, StringUtils.wrappedLinesEstimate("foobarbazfoobarbaz", 3)); assertEquals(1, StringUtils.wrappedLinesEstimate("foobarbazfoobarbaz", 20)); assertEquals(0, StringUtils.wrappedLinesEstimate("", 2)); }