JAVA往空格

JAVA去空格String ccc” he l l o , w o r l d “System.err.println(“去左边空:”ccc.replaceAll(“^\\s*”,

JAVA去空格
String ccc=” he l l o , w o r l d “;
System.err.println(“去左边空格:”+ccc.replaceAll(“^\\s*”, “”)+”————”);
System.err.println(“去右边空格:”+ccc.replaceAll(“\\s*$”, “”)+”————”);
System.err.println(“去所有空格:”+ccc.replaceAll(“\\s”, “”)+”————”);

System.err.println(“去两端空格:”+ccc.replaceAll(“^\\s*(.*?)\\s*$”,”$1″)+”————”);

来自: http://www.zhjie.net/java-spaces.htm