List of usage examples for java.lang String toCharArray
public char[] toCharArray()
From source file:Main.java
/** * Escape XML characters.//from w w w . j a va2 s . co m * Suggested by hussein_shafie * @param s value needed to be escaped * @return escaped value */ public static String escapeXML(final String s) { final char[] chars = s.toCharArray(); return escapeXML(chars, 0, chars.length); }
From source file:Anagram.java
/** * Sorts the passed-in string. /*from ww w . ja va 2 s .com*/ * * @return a sorted copy of the passed-in string */ protected static String sort(String string) { char[] charArray = string.toCharArray(); java.util.Arrays.sort(charArray); return new String(charArray); }
From source file:Main.java
/** * Rewrote the toLowercase method to improve performances. * In Ldap, attributesType are supposed to use ASCII chars : * 'a'-'z', 'A'-'Z', '0'-'9', '.' and '-' only. * // ww w .j a v a2s . com * @param value The String to lowercase * @return The lowercase string */ public static final String toLowerCase(String value) { char[] chars = value.toCharArray(); for (int i = 0; i < chars.length; i++) { chars[i] = LOWER_CASE[chars[i]]; } return new String(chars); }
From source file:Main.java
public static String getCurrentNumberString(String string) { String Current = string.replaceAll(" ", ""); char[] chars = Current.toCharArray(); String number = ""; for (int i = 8; i < chars.length - 6; i++) { number += chars[i];//from ww w. j av a 2 s .c o m } return toStringHex1(number); }
From source file:Main.java
public static byte[] getHexBytes(String message) { int len = message.length() / 2; char[] chars = message.toCharArray(); String[] hexStr = new String[len]; byte[] bytes = new byte[len]; for (int i = 0, j = 0; j < len; i += 2, j++) { hexStr[j] = "" + chars[i] + chars[i + 1]; bytes[j] = (byte) Integer.parseInt(hexStr[j], 16); }/* w w w.jav a 2 s . c o m*/ return bytes; }
From source file:Main.java
@SuppressWarnings("unused") private static int compareToBigInteger(String s1, String s2) { int ret = 0;//w w w .j a v a 2 s .c o m char[] c1 = s1.toCharArray(); char[] c2 = s2.toCharArray(); int index1 = 0, index2 = 0; while (index1 < c1.length && c1[index1] == '0') index1++; while (index2 < c2.length && c2[index2] == '0') index2++; if (c1.length - index1 != c2.length - index2) { ret = (c1.length - index1) - (c2.length - index2); } else { ret = c1[index1] - c2[index2]; } return ret; }
From source file:Main.java
public static byte[] setDevid(String devid) { String str = "0123456789ABCDEF"; char[] hexs = devid.toCharArray(); byte[] bytes = new byte[devid.length() / 2]; int n;/* ww w. j ava 2s . co m*/ for (int i = 0; i < bytes.length; i++) { n = str.indexOf(hexs[2 * i]) * 16; n += str.indexOf(hexs[2 * i + 1]); bytes[i] = (byte) (n & 0xff); } return bytes; }
From source file:com.sharpshim.yarc.util.HtmlUtil.java
private static String clearString(String str) { StringBuffer sb = new StringBuffer(); for (final Character c : str.toCharArray()) { if (c != null && c != '\uFEFF') { sb.append(c);/*ww w . ja v a 2 s.co m*/ } } return sb.toString(); }
From source file:Main.java
public static String hexStr2Str(String hexStr) { String str = "0123456789ABCDEF"; char[] hexs = hexStr.toCharArray(); byte[] bytes = new byte[hexStr.length() / 2]; int n;//from www . j a va 2 s . c o m for (int i = 0; i < bytes.length; i++) { n = str.indexOf(hexs[2 * i]) * 16; n += str.indexOf(hexs[2 * i + 1]); bytes[i] = (byte) (n & 0xff); } return new String(bytes); }
From source file:Main.java
public static String upper(String txtHeader) { if (txtHeader != null) { char[] stringArray = txtHeader.toCharArray(); stringArray[0] = Character.toUpperCase(stringArray[0]); txtHeader = new String(stringArray); return txtHeader; }/*from w ww . jav a 2 s . c o m*/ return null; }