Android String Trim trimSpace(String oldString)

Here you can find the source of trimSpace(String oldString)

Description

Method trim space

License

Open Source License

Parameter

Parameter Description
The string to be format.

Declaration

public static String trimSpace(String oldString) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* ww w  . java  2  s  . co  m*/
     * Method trim space
     *
     * @param The string to be format.
     *
     */
    public static String trimSpace(String oldString) {
        if (null == oldString)
            return null;
        if (0 == oldString.length())
            return "";

        StringBuffer sbuf = new StringBuffer();
        int oldLen = oldString.length();
        for (int i = 0; i < oldLen; i++) {
            if (' ' != oldString.charAt(i))
                sbuf.append(oldString.charAt(i));
        }
        String returnString = sbuf.toString();
        sbuf = null;
        return returnString;
    }

    /**
     * Method convert byte[] to String
     *
     * @param The string to be format.
     *
     */
    public static String toString(byte[] buffer) {
        if (null == buffer)
            return null;
        else
            return new String(buffer);
    }
}

Related

  1. ltrim(final String text, String trimText)
  2. rtrim(final String text)
  3. rtrim(final String text, String trimText)
  4. trimSuffix(final String text, final String suffix)
  5. trimPrefix(final String text, final String prefix)
  6. rightTrimSize(String s)
  7. trim(String s, char c)
  8. trim(String trimStr, String trimChars)
  9. trimEnd(String s, String extraChars)