Java Utililty Methods String Wrap

List of utility methods to do String Wrap

Description

The list of methods to do String Wrap are organized into topic(s).

Method

ListwrapText(String line, int maxLineLength)
wrap Text
List<String> wrappedLines = new ArrayList<>();
while (line.length() >= maxLineLength) {
    int lastSpaceIndex = line.substring(0, maxLineLength).lastIndexOf(" ");
    if (lastSpaceIndex == -1) {
        break;
    wrappedLines.add(line.substring(0, lastSpaceIndex));
    line = line.substring(lastSpaceIndex + 1, line.length());
...
String[]wrapText(String text, int len)
wrap Text
if (text == null)
    return new String[] {};
if (len <= 0)
    return new String[] { text };
if (text.length() <= len)
    return new String[] { text };
char[] chars = text.toCharArray();
Vector lines = new Vector();
...
String[]wrapText(String text, int len, boolean wordWrap)
It formats a long sentence to wrap into a desired width
if (text == null)
    return new String[] {};
if (len <= 0)
    return new String[] { text };
if (text.length() <= len)
    return new String[] { text };
char[] chars = text.toCharArray();
ArrayList<String> lines = new ArrayList<String>();
...
StringwrapText(String txt, char breakChar, String lineDelim, int numChars)
wrap Text
StringTokenizer tok = new StringTokenizer(txt, "" + breakChar);
String piece;
int lineLen = 0;
StringBuilder sb = new StringBuilder(txt.length() + 16);
while (tok.hasMoreTokens()) {
    piece = tok.nextToken();
    if (lineLen + piece.length() <= numChars)
        lineLen += piece.length();
...