Package org.jf.util
Class StringWrapper
java.lang.Object
org.jf.util.StringWrapper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String[]private static String[]private static String[]enlargeArray(String[] arr, int newLength) static voidprintWrappedString(PrintStream stream, String string, int maxWidth) static String[]wrapString(String str, int maxWidth, String[] output) Splits the given string into lines using on any embedded newlines, and wrapping the text as needed to conform to the given maximum line width.wrapStringOnBreaks(String string, int maxWidth) Splits the given string into lines of maximum width maxWidth.
-
Constructor Details
-
StringWrapper
public StringWrapper()
-
-
Method Details
-
wrapStringOnBreaks
Splits the given string into lines of maximum width maxWidth. The splitting is done using the current locale's rules for splitting lines.- Parameters:
string- The string to splitmaxWidth- The maximum length of any line- Returns:
- An iterable of Strings containing the wrapped lines
-
wrapString
Splits the given string into lines using on any embedded newlines, and wrapping the text as needed to conform to the given maximum line width. This uses and assumes unix-style newlines- Parameters:
str- The string to splitmaxWidth- The maximum length of any lineoutput- If given, try to use this array as the return value. If there are more values than will fit into the array, a new array will be allocated and returned, while the given array will be filled with as many lines as would fit.- Returns:
- The split lines from the original, as an array of Strings. The returned array may be larger than the number of lines. If this is the case, the end of the split lines will be denoted by a null entry in the array. If there is no null entry, then the size of the array exactly matches the number of lines. The returned lines will not contain an ending newline
-
addString
-
addString
-
enlargeArray
-
printWrappedString
public static void printWrappedString(@Nonnull PrintStream stream, @Nonnull String string, int maxWidth)
-