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 addEscpage(String str) {
    char[] cs = str.toCharArray();
    StringBuilder sb = new StringBuilder("\"");
    int length = cs.length;
    for (int i = 0; i < length; i++) {
        if (cs[i] == '\"' || cs[i] == '\t' || cs[i] == '\n') {
            sb.append("\\");
        }//  w  w  w. j av  a2s  .c o m
        sb.append(cs[i]);
    }
    sb.append("\"");
    return sb.toString();
}

From source file:Main.java

public static boolean isAlpha(String name) {
    char[] chars = name.toCharArray();

    for (char c : chars) {
        if (!Character.isLetter(c)) {
            return false;
        }//from   w ww  . j av a2  s .c o  m
    }

    return true;
}

From source file:Main.java

public static String filterCharacters(String xml) {
    char[] array = xml.toCharArray();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < array.length; i++) {
        if (xml.charAt(i) < 0x9 || (xml.charAt(i) > 0xa && xml.charAt(i) < 0xf)) {
        } else {/*w w  w. j a  v  a2 s.c  om*/
            sb.append(array[i]);
        }
    }
    return sb.toString();
}

From source file:Main.java

public static byte[] asciiString(String fourcc) {
    char[] ch = fourcc.toCharArray();
    byte[] result = new byte[ch.length];
    for (int i = 0; i < ch.length; i++) {
        result[i] = (byte) ch[i];
    }//w ww  . j a  v  a  2 s . c  o  m
    return result;
}

From source file:Main.java

public static String ToDBC(String input) {
    char[] c = input.toCharArray();
    for (int i = 0; i < c.length; i++) {
        if (c[i] == 12288) {
            c[i] = (char) 32;
            continue;
        }//  ww  w.ja v  a2  s. c  o  m
        if (c[i] > 65280 && c[i] < 65375)
            c[i] = (char) (c[i] - 65248);
    }
    return new String(c);
}

From source file:Main.java

public static boolean isInt(String str) {
    char[] content = str.toCharArray();

    for (int i = 0; i < content.length; ++i) {
        if (content[i] > 57 || content[i] < 48) {
            return false;
        }//from   w  w  w.  j av  a 2s.c  o  m
    }

    return true;
}

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  ww. ja va2 s. c  o  m
        if (c[i] < 127)
            c[i] = (char) (c[i] + 65248);
    }
    return new String(c);
}

From source file:Main.java

public static boolean isAlpha(String name) {
    char[] chars = name.toCharArray();

    for (char c : chars) {
        if (!Character.isLetter(c)) {
            if (!Character.isWhitespace(c)) {
                return false;
            }/*from  w  ww  .  jav a 2  s .c  o m*/
        }
    }
    return true;
}

From source file:Main.java

public static boolean isExistSpecialSymbols(String str) {
    for (Character c : str.toCharArray()) {
        if (!Character.isDigit(c)) {
            if (!Character.isLetter(c)) {
                return true;
            }/*from   w  w  w.j  av a2  s. c  om*/
        }
    }
    return false;
}

From source file:Main.java

/**
 * 01 02 12 zhuang 1 2 12//from   w w  w. j  a v a 2s.  c o m
 *
 * @param data
 * @return
 */
public static String changeData_month(String data) {
    char[] chars = data.toCharArray();
    if (String.valueOf(chars[0]).equals("0")) {
        data = String.valueOf(chars[1]);
    } else {
        data = data;
    }
    return data;
}