Here you can find the source of trimSpace(String oldString)
Parameter | Description |
---|---|
The | string to be format. |
public static String trimSpace(String oldString)
//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); } }