Java String Remove removeSpaces(String orig)

Here you can find the source of removeSpaces(String orig)

Description

xxx yyy zzz becomes xxxyyyzzz.

License

Open Source License

Declaration

public static String removeSpaces(String orig) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    /**// w w w.  j  av  a 2s.com
     * xxx yyy zzz becomes xxxyyyzzz.
     */
    public static String removeSpaces(String orig) {
        StringTokenizer st = new StringTokenizer(orig, " ");
        StringBuffer sb = new StringBuffer(orig.length());
        while (st.hasMoreTokens()) {
            sb.append(st.nextToken());
        }
        if (sb.toString().length() == 0)
            return orig;
        return sb.toString();
    }
}

Related

  1. removePropertyNameModifier(String name)
  2. removePunctuation(String str)
  3. removePunctuation(String value)
  4. removeRecursive(Object json, String keyToRemove)
  5. removeSomeOne(String words, int count)
  6. removeSpecialChars(final String word)
  7. removeSpecialCharsForSQLRegExp(String _s)
  8. removeUnusedData(String songData)
  9. removeWaitStatus(String nodeInfo)