List of usage examples for java.lang Character isSpaceChar
public static boolean isSpaceChar(int codePoint)
From source file:Main.java
public static void main(String[] argv) { System.out.println("is space char:" + Character.isSpaceChar('a')); }
From source file:Main.java
public static void main(String[] args) { char ch1 = ' '; char ch2 = '\u2028'; // LINE_SEPARATOR boolean b1 = Character.isSpaceChar(ch1); boolean b2 = Character.isSpaceChar(ch2); System.out.println("ch1 is a space character is " + b1); System.out.println("ch2 is a space character is " + b2); }
From source file:Main.java
public static void main(String[] args) { int cp1 = 0x2029; // PARAGRAPH_SEPARATOR int cp2 = 0x1010; boolean b1 = Character.isSpaceChar(cp1); boolean b2 = Character.isSpaceChar(cp2); System.out.println("cp1 represents a space character is " + b1); System.out.println("cp2 represents a space character is " + b2); }
From source file:Main.java
public static void main(String[] args) throws java.io.IOException { char c = 'a'; System.out.println("Character = " + (int) c); System.out.println("Defined = " + Character.isDefined(c)); System.out.println("Digit = " + Character.isDigit(c)); System.out.println("Ignorable = " + Character.isIdentifierIgnorable(c)); System.out.println("ISO control = " + Character.isISOControl(c)); System.out.println("Java identifier part = " + Character.isJavaIdentifierPart(c)); System.out.println("Java identifier start = " + Character.isJavaIdentifierStart(c)); System.out.println("Letter = " + Character.isLetter(c)); System.out.println("Letter or digit = " + Character.isLetterOrDigit(c)); System.out.println("Lowercase = " + Character.isLowerCase(c)); System.out.println("Space = " + Character.isSpaceChar(c)); System.out.println("Titlecase = " + Character.isTitleCase(c)); System.out.println("Unicode identifier part = " + Character.isUnicodeIdentifierPart(c)); System.out.println("Unicode identifier start = " + Character.isUnicodeIdentifierStart(c)); System.out.println("Uppercase = " + Character.isUpperCase(c)); System.out.println("White space = " + Character.isWhitespace(c)); byte[] types = { Character.COMBINING_SPACING_MARK, Character.CONNECTOR_PUNCTUATION, Character.CONTROL, Character.CURRENCY_SYMBOL, Character.DASH_PUNCTUATION, Character.DECIMAL_DIGIT_NUMBER, Character.ENCLOSING_MARK, Character.END_PUNCTUATION, Character.FORMAT, Character.LETTER_NUMBER, Character.LINE_SEPARATOR, Character.LOWERCASE_LETTER, Character.MATH_SYMBOL, Character.MODIFIER_SYMBOL, Character.NON_SPACING_MARK, Character.OTHER_LETTER, Character.OTHER_NUMBER, Character.OTHER_PUNCTUATION, Character.OTHER_SYMBOL, Character.PARAGRAPH_SEPARATOR, Character.PRIVATE_USE, Character.SPACE_SEPARATOR, Character.START_PUNCTUATION, Character.SURROGATE, Character.TITLECASE_LETTER, Character.UNASSIGNED, Character.UPPERCASE_LETTER }; String[] typeNames = { "Combining spacing mark", "Connector punctuation", "Control", "Currency symbol", "Dash punctuation", "Decimal digit number", "Enclosing mark", "End punctuation", "Format", "Letter number", "Line separator", "Lowercase letter", "Math symbol", "Modifier symbol", "Non spacing mark", "Other letter", "Other number", "Other punctuation", "Other symbol", "Paragraph separator", "Private use", "Space separator", "Start punctuation", "Surrogate", "Titlecase letter", "Unassigned", "Uppercase letter" }; int type = Character.getType(c); for (int i = 0; i < types.length; i++) if (type == types[i]) { System.out.println("Type name = " + typeNames[i]); break; }// ww w . jav a 2 s.com System.out.println("Unicode block = " + Character.UnicodeBlock.of(c)); }
From source file:Classify.java
public static void main(String[] args) throws java.io.IOException { char c = '\u0beb'; // Tamil digit. System.out.println("Character = " + (int) c); System.out.println("Defined = " + Character.isDefined(c)); System.out.println("Digit = " + Character.isDigit(c)); System.out.println("Ignorable = " + Character.isIdentifierIgnorable(c)); System.out.println("ISO control = " + Character.isISOControl(c)); System.out.println("Java identifier part = " + Character.isJavaIdentifierPart(c)); System.out.println("Java identifier start = " + Character.isJavaIdentifierStart(c)); System.out.println("Letter = " + Character.isLetter(c)); System.out.println("Letter or digit = " + Character.isLetterOrDigit(c)); System.out.println("Lowercase = " + Character.isLowerCase(c)); System.out.println("Space = " + Character.isSpaceChar(c)); System.out.println("Titlecase = " + Character.isTitleCase(c)); System.out.println("Unicode identifier part = " + Character.isUnicodeIdentifierPart(c)); System.out.println("Unicode identifier start = " + Character.isUnicodeIdentifierStart(c)); System.out.println("Uppercase = " + Character.isUpperCase(c)); System.out.println("White space = " + Character.isWhitespace(c)); byte[] types = { Character.COMBINING_SPACING_MARK, Character.CONNECTOR_PUNCTUATION, Character.CONTROL, Character.CURRENCY_SYMBOL, Character.DASH_PUNCTUATION, Character.DECIMAL_DIGIT_NUMBER, Character.ENCLOSING_MARK, Character.END_PUNCTUATION, Character.FORMAT, Character.LETTER_NUMBER, Character.LINE_SEPARATOR, Character.LOWERCASE_LETTER, Character.MATH_SYMBOL, Character.MODIFIER_SYMBOL, Character.NON_SPACING_MARK, Character.OTHER_LETTER, Character.OTHER_NUMBER, Character.OTHER_PUNCTUATION, Character.OTHER_SYMBOL, Character.PARAGRAPH_SEPARATOR, Character.PRIVATE_USE, Character.SPACE_SEPARATOR, Character.START_PUNCTUATION, Character.SURROGATE, Character.TITLECASE_LETTER, Character.UNASSIGNED, Character.UPPERCASE_LETTER }; String[] typeNames = { "Combining spacing mark", "Connector punctuation", "Control", "Currency symbol", "Dash punctuation", "Decimal digit number", "Enclosing mark", "End punctuation", "Format", "Letter number", "Line separator", "Lowercase letter", "Math symbol", "Modifier symbol", "Non spacing mark", "Other letter", "Other number", "Other punctuation", "Other symbol", "Paragraph separator", "Private use", "Space separator", "Start punctuation", "Surrogate", "Titlecase letter", "Unassigned", "Uppercase letter" }; int type = Character.getType(c); for (int i = 0; i < types.length; i++) if (type == types[i]) { System.out.println("Type name = " + typeNames[i]); break; }//from w w w . j a va2 s. c o m System.out.println("Unicode block = " + Character.UnicodeBlock.of(c)); }
From source file:Main.java
public static String flatten(String str, boolean removeSpaceChar) { StringBuilder buffer = new StringBuilder(); boolean previousWhite = true; for (int i = 0; i < str.length(); i++) { char ch = str.charAt(i); if (ch == '\r' || ch == '\n') { } else if (Character.isWhitespace(ch) || Character.isSpaceChar(ch)) { if (removeSpaceChar) { if (!previousWhite) { buffer.append(' '); }//from ww w . ja v a 2 s . c o m previousWhite = true; } else { buffer.append(ch); } } else { buffer.append(ch); previousWhite = false; } } return buffer.toString(); }
From source file:Main.java
public static String computePhraseShape(String x) { StringBuilder buf = new StringBuilder(); char lastc = 0; for (int i = 0; i < x.length(); i++) { char c = x.charAt(i); if (Character.isDigit(c)) c = '0'; else if (Character.isLetter(c)) c = Character.isLowerCase(c) ? 'a' : 'A'; else if (Character.isWhitespace(c) || Character.isSpaceChar(c)) c = ' '; if (c != lastc) buf.append(c);// ww w . j av a2 s . c o m lastc = c; } return buf.toString(); }
From source file:Main.java
/** * Make a list of all URL's that can be found in a string. * @param aSource A string, possibly containing URL's. * @return A List of URL's that could be scraped from the string. *//* w w w. j a v a 2 s.c om*/ public static java.util.List<String> extractUrl(String aSource) { final String lPrefix = "http://"; final java.util.List<String> lResult = new ArrayList<String>(); String lTodo = aSource; int lUrlPos = lTodo.indexOf(lPrefix); while (lUrlPos >= 0) { lUrlPos += lPrefix.length(); StringBuilder lUrlBuf = new StringBuilder(); while ((lUrlPos < lTodo.length()) && lTodo.charAt(lUrlPos) != '\n' && !Character.isSpaceChar(lTodo.charAt(lUrlPos))) lUrlBuf.append(lTodo.charAt(lUrlPos++)); lResult.add(lUrlBuf.toString()); if (lUrlPos < lTodo.length()) lTodo = lTodo.substring(lUrlPos); else lTodo = ""; lUrlPos = lTodo.indexOf(lPrefix); } return lResult; }
From source file:Main.java
public static void escapedAdd(final StringBuilder sb, final String str) { for (int i = 0; i < str.length(); i++) { final char ch = str.charAt(i); if (ch < 33 || Character.isWhitespace(ch) || Character.isSpaceChar(ch)) { sb.append(' '); } else {// w ww. j av a 2s . c o m switch (ch) { case '"': sb.append("""); break; case '\'': sb.append("'"); break; case '<': sb.append("<"); break; case '>': sb.append(">"); break; case '&': sb.append("&"); break; default: sb.append(ch); break; } } } }
From source file:Main.java
/** * Gets the end pos./* ww w .ja v a2 s. co m*/ * * @param query the query * @param backTrackIndex the back track index * @param backTrackStr the back track str * @return the end pos */ private static int getEndPos(String query, int backTrackIndex, String... backTrackStr) { if (backTrackStr != null) { String q = query.substring(0, backTrackIndex).toLowerCase(); for (int i = 0; i < backTrackStr.length; i++) { if (q.trim().endsWith(backTrackStr[i].toLowerCase())) { backTrackIndex = q.lastIndexOf(backTrackStr[i].toLowerCase()); break; } } } while (Character.isSpaceChar(query.charAt(backTrackIndex - 1))) { backTrackIndex--; } return backTrackIndex; }