List of usage examples for java.lang String charAt
public char charAt(int index)
From source file:Main.java
public static boolean isHexString(String key) { for (int i = key.length() - 1; i >= 0; i--) { final char c = key.charAt(i); if (!(c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f')) { return false; }//from w ww . j a v a2s . c o m } return true; }
From source file:Main.java
private static int getColorKeySeparator(String title) { for (int i = title.length() - 1; i >= 0; i--) { char c = title.charAt(i); if ('0' <= c && c <= '9') continue; if ((c == '$') && (i + 1 < title.length())) return i; // $ and at least one digit break;/* w ww . j a v a 2s . c o m*/ } return -1; }
From source file:Main.java
/** * Return the last char in string. This is useful when trailing quotemark is missing on an attribute * @param str String/*w w w . j a v a2 s. co m*/ * @return last char in String */ public static int lastChar(String str) { if (str != null && str.length() > 0) { return str.charAt(str.length() - 1); } return 0; }
From source file:Main.java
public static String revStr(String s) { StringBuilder sb = new StringBuilder(); for (int i = s.length() - 1; i >= 0; i--) { sb.append(s.charAt(i)); }/*from ww w. ja va 2 s . c o m*/ return sb.toString(); }
From source file:Main.java
public static boolean isValidBase64Encoding(String data) { for (int i = 0; i < data.length(); i++) { char ch = data.charAt(i); if (ch == BASE64PAD || ch < DECODETABLE.length && DECODETABLE[ch] != Byte.MAX_VALUE) { // do nothing } else if (ch == '\r' || ch == '\n') { // do nothing } else {//from w w w . ja v a2s . c o m return false; } } return true; }
From source file:Main.java
public static String javaToDexName(String javaName) { javaName = javaName.replace('.', '/'); if (javaName.length() > 1 && javaName.charAt(javaName.length() - 1) != ';') { javaName = 'L' + javaName + ';'; }/* w w w. j a va 2 s . co m*/ return javaName; }
From source file:Main.java
private static String removeBadFirstCharacters(String line) { boolean shouldRemove = false; char first = line.charAt(0); for (char badFirstSymbol : BAD_FIRST_SYMBOLS) { if (first == badFirstSymbol) { shouldRemove = true;// ww w . java2 s .c o m break; } } return shouldRemove ? line.substring(1) : line; }
From source file:Main.java
private static boolean checkNum(String sCard2) { for (int i = 0, len = sCard2.length() - 1; i < len; i++) { if ((sCard2.charAt(i) > '9' || sCard2.charAt(i) < '0')) { return false; }//from w w w . j a v a 2 s . c o m } return true; }
From source file:Main.java
/** * Get the mnemonic from the given text. The mnemonic is marked by a leading & character. * @param text The mnemonic search text. * @return The mnemonic or -1 if no mnemonic could be found. *///from w w w .j ava 2s . co m public static int getMnemonicKeyCode(String text) { for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (c == '&') { try { return (int) text.charAt(i + 1); } catch (IndexOutOfBoundsException e) { return -1; } } } return -1; }
From source file:Main.java
public static String capitalizeFirstLetter(String str) { if (isEmpty(str)) { return str; }/* w w w . j av a 2 s . co m*/ char c = str.charAt(0); return (!Character.isLetter(c) || Character.isUpperCase(c)) ? str : new StringBuilder(str.length()).append(Character.toUpperCase(c)).append(str.substring(1)) .toString(); }