List of usage examples for java.lang String toCharArray
public char[] toCharArray()
From source file:Main.java
public static String filter(String xmlStr) { StringBuilder sb = new StringBuilder(); char[] chs = xmlStr.toCharArray(); //log.debug("filter before=" +chs.length); for (char ch : chs) { if ((ch >= 0x00 && ch <= 0x08) || (ch >= 0x0b && ch <= 0x0c) || (ch >= 0x0e && ch <= 0x1f)) { //eat... } else {//from w ww . j a v a2 s. c o m sb.append(ch); } } //log.debug("filter after=" +sb.length()); return sb.toString(); }
From source file:Main.java
private static int getSlashCount(String string) { int count = 0; char[] pathChars = string.toCharArray(); for (char pathChar : pathChars) { if (pathChar == '/') { count++;//from w w w. j av a2s .c o m } } return count; }
From source file:Main.java
public static boolean isChinese(String strName) { char[] ch = strName.toCharArray(); for (int i = 0; i < ch.length; i++) { char c = ch[i]; if (isChinese(c) == true) { return isChinese(c); } else {/*from w w w. j a va2 s . c o m*/ return isChinese(c); } } return false; }
From source file:client.Client.java
static String fromHex(String input) { try {//from w w w . j av a 2 s. c o m return new String(Hex.decodeHex(input.toCharArray())); } catch (Exception e) { return new String(); } }
From source file:Main.java
public final static String initCap(String s) { String str = ""; try {//from w w w .j a va2 s . co m str = s.toLowerCase(); char[] ca = str.toCharArray(); char c = new String(new char[] { ca[0] }).toUpperCase().toCharArray()[0]; ca[0] = c; str = new String(ca); } catch (Exception ignore) { } return str; }
From source file:Main.java
/** * VLC authorize only "-._~" in Mrl format, android Uri authorize "_-!.~'()*". * Therefore, decode the characters authorized by Android Uri when creating an Uri from VLC. *//* www .j a v a 2s . com*/ public static Uri UriFromMrl(String mrl) { final char array[] = mrl.toCharArray(); final StringBuilder sb = new StringBuilder(array.length * 2); for (int i = 0; i < array.length; ++i) { final char c = array[i]; if (c == '%') { if (array.length - i >= 3) { try { final int hex = Integer.parseInt(new String(array, i + 1, 2), 16); if (URI_AUTHORIZED_CHARS.indexOf(hex) != -1) { sb.append((char) hex); i += 2; continue; } } catch (NumberFormatException ignored) { } } } sb.append(c); } return Uri.parse(sb.toString()); }
From source file:Main.java
public static String ToDBC(String input) { if (input == null) return null; char[] c = input.toCharArray(); for (int i = 0; i < c.length; i++) { if (c[i] == 12288) { c[i] = (char) 32; continue; }/*from w w w . java2 s. co m*/ if (c[i] > 65280 && c[i] < 65375) c[i] = (char) (c[i] - 65248); } return new String(c); }
From source file:epgtools.dumpepgfromts.test.common.TestSection.java
private static Section getSdt(String sdtHexDump) throws DecoderException { char[] xc = sdtHexDump.toCharArray(); byte[] xb = Hex.decodeHex(xc); return new Section(xb); }
From source file:Main.java
public static final byte[] base32ToByteArray(String str, int nBytes) { char[] chars = str.toCharArray(); byte[] result = new byte[nBytes]; int bitBuffer = 0, nBitsInBuffer = 0; int charIndex = 0; for (int byteIndex = 0; byteIndex < nBytes && charIndex < chars.length; byteIndex++) { while (nBitsInBuffer < 8 && charIndex < chars.length) { byte newBits = charToBitsMap[chars[charIndex++]]; bitBuffer <<= 5;/*from w w w. j a va 2 s .c o m*/ bitBuffer |= newBits; nBitsInBuffer += 5; } nBitsInBuffer -= 8; result[byteIndex] = (byte) (bitBuffer >> nBitsInBuffer); } 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 w w w . j a v a 2 s .c o m } return true; }