List of usage examples for java.lang Character isWhitespace
public static boolean isWhitespace(int codePoint)
From source file:Main.java
/** * Checks if a node value is blank (contains only white spaces). * // w ww . j a va 2s .co m * @param value * The value to check * @return false if the value is null or a non white space character is * found */ public static boolean isBlank(String value) { if (value == null) { return false; } for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); if (!Character.isWhitespace(c)) { return false; } } return true; }
From source file:Main.java
/** Returns whitespace-separated strings from the input stream, or null if the end of the stream has been reached */ public static String readToken(InputStream in) { StringBuilder sb = new StringBuilder(); boolean first = true; int ch;// www. j av a 2 s . c o m while (true) { try { ch = in.read(); if (ch == -1) return sb.length() > 0 ? sb.toString() : null; if (Character.isWhitespace(ch)) { if (first) continue; break; } sb.append((char) ch); first = false; } catch (IOException e) { break; } } return sb.toString(); }
From source file:Main.java
public static boolean isBlank(String str) { int strLen;//w w w. jav a2 s.c o m if ((str == null) || ((strLen = str.length()) == 0)) { return true; } for (int i = 0; i < strLen; i++) { if ((Character.isWhitespace(str.charAt(i)) == false)) { return false; } } return true; }
From source file:Main.java
/** * used in character() method of DefaultHandler subclasses to skip carriage * return type data//from www.ja v a 2s. com * * @param data * @param start * @param length * @return */ public static boolean isWhiteSpace(char[] data, int start, int length) { boolean result = true; for (int i = 0; i < length; i++) { if (!Character.isWhitespace(data[start + i])) { result = false; break; } } return result; }
From source file:Main.java
public static boolean isWhitespace(String s) { if (s == null) return false; for (char c : s.toCharArray()) { if (!Character.isWhitespace(c)) { return false; }//from www.j a va 2 s . co m } return true; }
From source file:Main.java
/** * Check whether the given CharSequence contains any whitespace characters. * * @param seq the CharSequence to check (may be {@code null}) * @return {@code true} if the CharSequence is not empty and * contains at least 1 whitespace character * @see java.lang.Character#isWhitespace * @since 3.0/*ww w.ja v a2 s. com*/ */ // From org.springframework.util.StringUtils, under Apache License 2.0 public static boolean containsWhitespace(final CharSequence seq) { if (isEmpty(seq)) { return false; } final int strLen = seq.length(); for (int i = 0; i < strLen; i++) { if (Character.isWhitespace(seq.charAt(i))) { return true; } } return false; }
From source file:Main.java
public static int getLeadingWhitespaceEnd(String string, int charStart, int charEnd) { for (int i = charStart; i < charEnd; i++) { if (!Character.isWhitespace(string.charAt(i))) { return i; }/*from ww w .ja v a 2 s . c om*/ } return charEnd; }
From source file:Main.java
public static int getTrailingWhitespaceStart(String string, int charStart, int charEnd) { for (int i = charEnd - 1; i >= charStart; i--) { if (!Character.isWhitespace(string.charAt(i))) { return i + 1; }/*from w w w. ja va 2s . c om*/ } return charStart; }
From source file:Main.java
/** * <p>//w w w . ja va2 s .c o m * Checks if a String is whitespace, empty ("") or null. * </p> * <p> * <pre> * StringUtils.isBlank(null) = true * StringUtils.isBlank("") = true * StringUtils.isBlank(" ") = true * StringUtils.isBlank("bob") = false * StringUtils.isBlank(" bob ") = false * </pre> * * @param str the String to check, may be null * @return <code>true</code> if the String is null, empty or whitespace */ public static boolean isBlank(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if ((!Character.isWhitespace(str.charAt(i)))) { return false; } } return true; }
From source file:Main.java
public static boolean isAllWhitespace(String string) { if (string == null) { return false; }/*from w w w .j av a2 s. c o m*/ char[] characters = string.toCharArray(); for (int i = 0; i < characters.length; i++) { if (!Character.isWhitespace(characters[i])) { return false; } } return true; }