Java Utililty Methods String Break

List of utility methods to do String Break

Description

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

Method

String[]breakString(String input, int partLength)
break String
int numParts = input.length() / partLength;
if (input.length() % partLength > 0)
    numParts++;
String[] parts = new String[numParts];
int startIndex, endIndex;
for (int i = 0; i < numParts; i++) {
    startIndex = i * partLength;
    endIndex = startIndex + partLength;
...
StringbreakString(String remainingStr, String soFar, int maxLineLength)
Creates html representation of a given string that includes line breaks
if (remainingStr.length() < maxLineLength) {
    return "<html>" + soFar + remainingStr + "</html>";
int endIndex;
if (maxLineLength > remainingStr.length()) {
    endIndex = remainingStr.length();
} else {
    endIndex = maxLineLength;
...
StringbreakString(String str, int maxLineLenght)
Break a string into lines with maximum length of maxLineLenght.
StringBuffer sb = new StringBuffer();
int pos = 0;
for (int i = 0; i < str.length(); i++) {
    sb.append(str.charAt(i));
    if (++pos > maxLineLenght) {
        if (str.charAt(i) == ' ') {
            sb.append('\n');
            pos = 0;
...
StringbreakString(String string, int l, String newLine)
Breaks a String for showing.
int length = (l == 0) ? 80 : l;
int inserts = string.length() / length;
StringBuilder b = new StringBuilder(string);
for (int k = 0; k < inserts; k++) {
    b.insert(length * (k + 1), newLine);
return b.toString();
StringbreakString(String text, int maxsize)
break String
if (text.length() < maxsize) {
    return text;
return text.substring(0, maxsize) + "\n" + breakString(text.substring(maxsize), maxsize);
StringbreakString(String theString)
Breaks the String theString at position #CONSOLE_WIDTH and adds a linebreak.
return (breakString("", theString, CONSOLE_WIDTH));