List of usage examples for java.lang String toCharArray
public char[] toCharArray()
From source file:Main.java
public static boolean isWholePositiveNumber(String value) { if (value == null) { return false; }//from w w w . j a va2 s .c om for (char c : value.toCharArray()) { if (!Character.isDigit(c)) { return false; } } return true; }
From source file:Main.java
public static String revers(String num) { num = num.toUpperCase();//from w ww .jav a2s .com char array[] = num.toCharArray(); for (int i = 0; i < array.length; i++) { if (array[i] == 'A') array[i] = reverseToChar(15 - 10); else if (array[i] == 'B') array[i] = reverseToChar(15 - 11); else if (array[i] == 'C') array[i] = reverseToChar(15 - 12); else if (array[i] == 'D') array[i] = reverseToChar(15 - 13); else if (array[i] == 'E') array[i] = reverseToChar(15 - 14); else if (array[i] == 'F') array[i] = reverseToChar(15 - 15); else array[i] = reverseToChar(15 - Integer.parseInt(String.valueOf(array[i]))); } // return String.valueOf(array); }
From source file:Main.java
public static int getStringLen(String SrcStr) { int return_value = 0; if (SrcStr != null) { char[] theChars = SrcStr.toCharArray(); for (int i = 0; i < theChars.length; i++) { return_value += (theChars[i] <= 255) ? 1 : 2; }/*from w w w. ja v a 2 s. c o m*/ } return return_value; }
From source file:Main.java
/** * Create document from given string content. * @param data content of xml document * @return//from w ww . j ava 2 s . co m * @throws IllegalArgumentException */ public static Document createDocument(String data) throws IllegalArgumentException { return createDocument(data.toCharArray()); }
From source file:Main.java
public static String removeGreaterLessThan5(String numStr, boolean which) { StringBuilder builder = new StringBuilder(); for (char c : numStr.toCharArray()) { if (isGreaterThan5(c) ^ which) { builder.append(c);/* ww w . j a v a2s . c om*/ } } return builder.toString(); }
From source file:Main.java
public static String removeDigit(String numStr, boolean which) { StringBuilder builder = new StringBuilder(); for (char c : numStr.toCharArray()) { if (isOddDigit(c) ^ which) { builder.append(c);/* w w w . j a v a 2s . c o m*/ } } return builder.toString(); }
From source file:Main.java
public static String getRandom(String source, int length) { return TextUtils.isEmpty(source) ? null : getRandom(source.toCharArray(), length); }
From source file:Main.java
/** * Symmetric algorithm used for ciphering/deciphering. * * @param message message//from w w w. ja v a2 s .c o m * @param salt salt * @return ciphered/deciphered message */ @NonNull public static String x(@NonNull String message, @NonNull String salt) { final char[] m = message.toCharArray(); final char[] s = salt.toCharArray(); final int ml = m.length; final int sl = s.length; final char[] result = new char[ml]; for (int i = 0; i < ml; i++) { result[i] = (char) (m[i] ^ s[i % sl]); } return new String(result); }
From source file:Main.java
/** * Changes extend ASCII and non ASCII into HTML encoded ascii string. * @param notAscii the string to change/*from www . j a v a 2 s. com*/ * @return the converted string */ public static String toExtendedAscii(String notAscii) { StringBuilder builder = new StringBuilder(); char[] charArray = notAscii.toCharArray(); for (int i = 0; i < charArray.length; ++i) { char a = charArray[i]; if ((int) a > 127) { builder.append("&#" + (int) a + ";"); } else { builder.append(a); } } return builder.toString(); }
From source file:Main.java
/** * encode Unicode string//from ww w.ja va 2s .c o m * * @param s s * @return string */ public static String encodeUnicodeStr(String s) { StringBuilder sb = new StringBuilder(s.length() * 3); for (char c : s.toCharArray()) { if (c < 256) { sb.append(c); } else { sb.append("\\u"); sb.append(Character.forDigit((c >>> 12) & 0xf, 16)); sb.append(Character.forDigit((c >>> 8) & 0xf, 16)); sb.append(Character.forDigit((c >>> 4) & 0xf, 16)); sb.append(Character.forDigit((c) & 0xf, 16)); } } return sb.toString(); }