Example usage for java.lang String toCharArray

List of usage examples for java.lang String toCharArray

Introduction

In this page you can find the example usage for java.lang String toCharArray.

Prototype

public char[] toCharArray() 

Source Link

Document

Converts this string to a new character array.

Usage

From source file:Main.java

public static String getNumberFromCode(String code) {

    char codeArray[] = code.toCharArray();

    String numbers = "";

    for (int i = 0; i < codeArray.length; i++) {
        int intNumber = (int) codeArray[i] - 1632;
        numbers += Character.toString((char) (intNumber + 48));
    }/*from   ww  w .  j a v a2  s. com*/

    return numbers;
}

From source file:Main.java

public static final boolean isChineseCharacter(String chineseStr) {
    char[] charArr = chineseStr.toCharArray();
    for (int i = 0; i < charArr.length; i++) {
        if ((charArr[i] >= '\u0000' && charArr[i] < '\uFFFD')
                || (charArr[i] > '\uFFFD' && charArr[i] < '\uFFFF')) {
            continue;
        } else {/*  w w  w  .  j  av  a2s. com*/
            return false;
        }
    }
    return true;
}

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)) {
            return true;
        }/*  w  w w .ja  va  2  s  . co  m*/
    }
    return false;
}

From source file:Main.java

private static String recoverIndex(String strCode) {
    char[] chars = strCode.toCharArray();
    char temp;//from w w w.  ja  v a2s.c o  m
    temp = chars[0];
    chars[0] = chars[chars.length - 1];
    chars[chars.length - 1] = temp;
    for (int i = 0; i < chars.length; i++) {
        if (i != 0 && i % 2 == 0) {
            temp = chars[i - 1];
            chars[i - 1] = chars[i];
            chars[i] = temp;
        }
    }
    return new String(chars);
}

From source file:Main.java

public static String getCodeFromNumber(String number) {

    char[] numberArray = number.toCharArray();

    String character = "";

    for (int i = 0; i < numberArray.length; i++) {
        int intNumber = ((int) numberArray[i] - 48);
        character += Character.toString((char) (intNumber + 1632));
    }/*w ww.j  a  va  2s  .com*/

    return character;
}

From source file:Main.java

public static String ToSBC(String input) {

    char[] c = input.toCharArray();
    for (int i = 0; i < c.length; i++) {
        if (c[i] == 32) {
            c[i] = (char) 12288;
            continue;
        }/*from  w w  w.j  a v  a2s  .  c om*/
        if (c[i] < 127 && c[i] > 32)
            c[i] = (char) (c[i] + 65248);
    }
    return new String(c);
}

From source file:Main.java

public static int searchChar(String str) {
    char[] c = str.toCharArray();
    int i = 0;//from   w w w . j av a2  s.  c  om
    for (i = 0; i < c.length; i++) {
        if (!Character.isDigit(c[i]))
            return i;
    }
    return 0;
}

From source file:Main.java

/**
 * Will remove all occurrences of the characters '&lt;', '&gt;', '[', ']', '{' and '}'
 * from the input string and return the result. Beware: While <code>chopBraces()</code>
 * only removes those characters from the beginning and end of a string, <code>stripBraces()</code>
 * will remove characters from all positions in the string.
 * @param s//from  w  ww .j  a v  a  2  s .  c om
 * @return
 */
public static String stripBraces(String s) {
    char c[] = s.toCharArray();
    char tmp[] = new char[c.length];

    int id = 0;
    for (int i = 0; i < c.length; i++) {
        char cc = c[i];
        if (cc != '<' && cc != '>' && cc != '[' && cc != ']' && cc != '{' && cc != '}')
            tmp[id++] = c[i];
    }

    char res[] = new char[id];
    System.arraycopy(tmp, 0, res, 0, id);
    return new String(res);
    //      
    //      if(s==null || (s.indexOf('[')<0 && s.indexOf('{')<0)) return s;
    //      return s.substring(1,s.length()-1);      
}

From source file:Main.java

private static String reversal(String s) {
    String result = "";
    char[] cs = s.toCharArray();
    for (int i = cs.length - 1; i > -1; i--) {
        result += String.valueOf(cs[i]);
    }/*from   w  w  w  .  j  av  a2 s .  com*/
    return result;
}

From source file:Main.java

public static String getIntiCapString(String param) {
    if (param != null && param.length() > 0) {
        char[] charArray = param.toCharArray();
        charArray[0] = Character.toUpperCase(charArray[0]);
        return new String(charArray);
    } else {// www . ja  v  a 2  s  .  c om
        return "";
    }
}