Java Utililty Methods Char Array Create

List of utility methods to do Char Array Create

Description

The list of methods to do Char Array Create are organized into topic(s).

Method

char[]charArray(int arraySize)
char Array
char[] result = new char[arraySize];
for (int i = 0; i < arraySize; i++) {
    result[i] = 'a';
return result;
StringcharArrayLiteral(CharSequence cs)
char Array Literal
if (cs == null) {
    return "null";
StringBuilder sb = new StringBuilder();
sb.append('{');
int len = cs.length();
for (int i = 0; i < len; i++) {
    sb.append(" \'");
...
Character[]toCharacterArray(String s)
to Character Array
if (s == null)
    return null;
final Character[] c = new Character[s.length()];
for (int i = 0; i < c.length; i++) {
    c[i] = s.charAt(i);
return c;
char[]toCharArray(boolean[] array)
Coverts given booleans array to array of chars.
char[] result = new char[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i] ? (char) 1 : (char) 0;
return result;
char[]toCharArray(byte[] barr)
Converts byte array to char array.
if (barr == null) {
    return null;
char[] carr = new char[barr.length];
for (int i = 0; i < barr.length; i++) {
    carr[i] = (char) barr[i];
return carr;
...
char[]toCharArray(byte[] byteArray)
A utility method to convert from bytes to chars
if (byteArray == null) {
    return null;
char[] result = new char[byteArray.length];
for (int i = 0; i < byteArray.length; i++) {
    result[i] = (char) byteArray[i];
return result;
...
char[]toCharArray(byte[] data)
to Char Array
if ((data == null) || (data.length % 2 != 0)) {
    return null;
char[] chrs = new char[data.length / 2];
for (int i = 0; i < chrs.length; i++) {
    chrs[i] = toChar(new byte[] { data[(i * 2)], data[(i * 2) + 1], });
return chrs;
...
char[]toCharArray(byte[] input)
Rewrite a byte array as a char array
char[] result = new char[input.length];
for (int i = 0; i < input.length; i++) {
    result[i] = (char) input[i];
return result;
char[]toCharArray(byte[] src)
to Char Array
char[] arr = new char[src.length / 2];
for (int i = 0; i < arr.length; i++) {
    arr[i] = (char) (((0xff & (src[i * 2])) << 8) | (0xff & src[i * 2 + 1]));
return arr;
char[]toCharArray(char... values)
to Char Array
char[] array = new char[values.length];
System.arraycopy(values, 0, array, 0, values.length);
return array;