List of usage examples for java.lang String charAt
public char charAt(int index)
From source file:Main.java
public static boolean compareString(byte[] barray, String str, int size) { for (int i = 0; i < size; ++i) { int m = barray[i]; int n = str.charAt(i); if (m != n) return false; }//from w w w . j a va2 s . co m return true; }
From source file:Main.java
public static int calculateLengthWithByte(String str) { int length = 0; for (int i = 0; i < str.length(); i++) { char tmp = str.charAt(i); if (tmp > 0 && tmp < 127) { length += 1;//from w w w . j a va 2s . co m } else { length += 2; } } return length; }
From source file:com.streamsets.pipeline.stage.origin.remote.FileFilter.java
/** * Convert a limited file glob into a simple regex. * * @param glob file specification glob/*from w w w . j a v a2 s . c om*/ * @return regex. */ private static String globToRegex(String glob) { if (glob.charAt(0) == '.' || glob.contains("/") || glob.contains("~")) { throw new IllegalArgumentException("Invalid character in file glob"); } // treat dot as a literal. glob = glob.replace(".", "\\."); glob = glob.replace("*", ".+"); glob = glob.replace("?", ".{1}+"); return glob; }
From source file:Main.java
/** Returns -1 if "value" is a negative double binary string,+1 if it is positive, 0 if "value" is not a well formed 64 binary string according to IEEE754 standard*/ public static int getDoubleSign(String value) { if (is64BinaryString(value)) { switch (value.charAt(0)) { case '0': return 1; case '1': return -1; }//www . j av a 2s .c o m } return 0; }
From source file:Main.java
private static boolean isCapsLock(String word) { for (int i = 0; i < word.length(); i++) { if (Character.isLowerCase(word.charAt(i))) return false; }//from w ww . j a va 2s. com return true; }
From source file:Main.java
public static String trimTrailing(String s) { int endIndex = s.length(); while (endIndex > 0 && s.charAt(endIndex - 1) <= ' ') endIndex--;// w w w . jav a 2 s . c o m return s.substring(0, endIndex); }
From source file:Main.java
public static boolean isPalindrome(String text) { String reverse = ""; for (int i = text.length() - 1; i >= 0; i--) { reverse += text.charAt(i); }/*from w w w .j ava2s . co m*/ return text.equals(reverse); }
From source file:Main.java
public static boolean isNumericString(String s) { boolean b = true; for (int i = 0; i < s.length(); i++) { if (!isNumeric(s.charAt(i))) { b = false;//from ww w . jav a2 s. c o m break; } } return b; }
From source file:Utils.java
/** * @param uri URI//from w w w. ja va 2 s .c om * @return True if the uri has a scheme */ public static boolean hasScheme(String uri) { for (int i = 0; i < uri.length(); i++) { char c = uri.charAt(i); if (c == ':') return true; if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || (i > 0 && (c >= '0' && c <= '9' || c == '.' || c == '+' || c == '-')))) break; } return false; }
From source file:Main.java
public static boolean IsNumeric(String number) { for (int i = 0; i < number.length(); i++) { if (!Character.isDigit(number.charAt(i))) return false; }// w ww . j av a2 s. c o m return true; }