java去中文
java 去中文
package a.b; public class TrimCNTool { public static boolean checkCNChar(char oneChar) { if ((oneChar >= '\u4e00' && oneChar <= '\u9fa5') || (oneChar >= '\uf900' && oneChar <= '\ufa2d')){ return true; }else{ return false; } } public static String deleteCNChar(String source) { char[] cs = source.toCharArray(); int length= cs.length; char [] buf = new char[length]; for (int i = 0; i <length; i++) { char c = cs[i]; if (!checkCNChar(c)) { buf[i] = c; } } String ret = new String(buf); return ret.trim(); } public static void main(String[] args) { String string = "很高兴遇见你Mr. King "; string = deleteCNChar(string); System.out.println(string); } }
感觉空虚寂寞,只是因为你无所关注,无处付出。