Android examples for java.lang:Character
Trim unicode space character
public class Main { public static String trimAllSpace(String input) { {//from ww w . ja v a 2s . com if (input == null) return ""; input = input.trim(); char[] charArray = input.toCharArray(); if (charArray.length == 0) { return ""; } int st = 0; int end = charArray.length - 1; while (st <= end && isSpaceChar(charArray[st])) { st++; } while (end >= st && isSpaceChar(charArray[end])) { end--; } return input.substring(st, end + 1); } } private static boolean isSpaceChar(char ch) { return ch == 32 || ch == 12288 || ch == 160 || ch == 9; } }