Java Utililty Methods String Whitespace Delete

List of utility methods to do String Whitespace Delete

Description

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

Method

StringdeleteWhitespace(String str)
delete Whitespace
if (str == null) {
    return "";
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
    char ch = str.charAt(i);
    if (!Character.isWhitespace(ch)) {
        buffer.append(ch);
...
StringdeleteWhitespace(String str)

Deletes all whitespaces from a String.

Whitespace is defined by Character#isWhitespace(char) .

StringBuilder buffer = new StringBuilder();
int sz = str.length();
for (int i = 0; i < sz; i++) {
    if (!Character.isWhitespace(str.charAt(i))) {
        buffer.append(str.charAt(i));
return buffer.toString();
...
StringdeleteWhitespace(String str)

Deletes all whitespaces from a String.

StringBuffer buffer = new StringBuffer();
int sz = str.length();
for (int i = 0; i < sz; i++) {
    if (!Character.isWhitespace(str.charAt(i))) {
        buffer.append(str.charAt(i));
return buffer.toString();
...
StringdeleteWhitespace(String string)
delete Whitespace
return string.replaceAll("\\s", "");
StringdeleteWhitespaces(final String string)
Deletes all white-spaces from the given string.
if (string == null) {
    return null;
return string.replaceAll("\\s", ""); 
StringdeleteWhiteSpaces(String nodeValue)
delete White Spaces
int pos = 0;
while (Character.isSpace(nodeValue.charAt(pos))) {
    pos++;
return nodeValue.substring(pos, nodeValue.length());