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 enquoteIdentifier(String s) {
    char[] raw = s.toCharArray();
    StringBuilder stringBuilder = new StringBuilder();
    for (char c : raw) {
        if (c < ' ' || c > '') {
            stringBuilder.append("\\u").append(String.format("%04x", c));
            continue;
        }/*w  w  w  .j  av  a  2s.  c o  m*/
        stringBuilder.append(c);
    }
    return stringBuilder.toString();
}

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] == ' ') {
            c[i] = '\u3000';
        } else if (c[i] < '\177') {
            c[i] = (char) (c[i] + 65248);
        }//from w  w w .j  ava2 s  .c o m
    }
    return new String(c);
}

From source file:Main.java

public static String cleanBlankToString(String des) {
    char[] chars = des.toCharArray();
    StringBuffer sb = new StringBuffer();
    for (Character c : chars) {
        if (java.util.regex.Pattern.matches("\\d", String.valueOf(c))) {
            sb.append(c);/* w  w  w .j a  v a 2 s. c  o m*/
        }
    }
    return sb.toString();
}

From source file:Main.java

private static boolean containsOneWord(char c, String word) {
    char[] array = word.toCharArray();
    int count = 0;
    for (Character ch : array) {
        if (c == ch) {
            count++;//  ww  w  .ja va2s.  co  m
        }
    }
    return count == 1;
}

From source file:Main.java

public static byte[] stringToBytesUTFCustom(String str) {
    char[] buffer = str.toCharArray();
    byte[] b = new byte[buffer.length << 1];
    for (int i = 0; i < buffer.length; i++) {
        int bpos = i << 1;
        b[bpos] = (byte) ((buffer[i] & 0xFF00) >> 8);
        b[bpos + 1] = (byte) (buffer[i] & 0x00FF);
    }/*from w  w  w . j a  va  2s.c o m*/
    return b;
}

From source file:Main.java

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

From source file:Main.java

private static boolean isAllWords(String prefix) {
    char[] array = prefix.toCharArray();
    for (Character ch : array) {
        if (ch < 'A' || ch > 'z' || (ch < 'a' && ch > 'Z')) {
            return false;
        }//  w w  w . ja  va2  s .  c om
    }
    return true;
}

From source file:Main.java

public static boolean isExistNumber(String str) {
    for (Character c : str.toCharArray()) {
        if (Character.isDigit(c)) {
            return true;
        }/*from   ww  w  .j a v a2 s.  co m*/
    }
    return false;
}

From source file:Main.java

public static void coder(String textString) {
    for (char c : textString.toCharArray()) {
        codedText += characterTable.get(c);
    }//  w  ww . j av  a  2s .  c o m
}

From source file:Main.java

private static char[] getPaddedBytes(String source) {
    char[] converted = source.toCharArray();
    int requiredLength = 3 * ((converted.length + 2) / 3);
    char[] result = new char[requiredLength];
    System.arraycopy(converted, 0, result, 0, converted.length);
    return result;
}