Here you can find the source of toCharArray(final byte[] array)
public static char[] toCharArray(final byte[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static char[] toCharArray(final byte[] array) { return toCharArray(array, 0, array.length); }/*from w w w . j a v a 2s.c o m*/ public static char[] toCharArray(final byte[] array, final int off, final int len) { return toCharArray(array, off, len, new char[len], 0); } public static char[] toCharArray(final byte[] from, final int fromOff, final int len, final char[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (char) from[i]; } return to; } public static char[] toCharArray(final short[] array) { return toCharArray(array, 0, array.length); } public static char[] toCharArray(final short[] array, final int off, final int len) { return toCharArray(array, off, len, new char[len], 0); } public static char[] toCharArray(final short[] from, final int fromOff, final int len, final char[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (char) from[i]; } return to; } public static char[] toCharArray(final int[] array) { return toCharArray(array, 0, array.length); } public static char[] toCharArray(final int[] array, final int off, final int len) { return toCharArray(array, off, len, new char[len], 0); } public static char[] toCharArray(final int[] from, final int fromOff, final int len, final char[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (char) from[i]; } return to; } public static char[] toCharArray(final long[] array) { return toCharArray(array, 0, array.length); } public static char[] toCharArray(final long[] array, final int off, final int len) { return toCharArray(array, off, len, new char[len], 0); } public static char[] toCharArray(final long[] from, final int fromOff, final int len, final char[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (char) from[i]; } return to; } public static char[] toCharArray(final float[] array) { return toCharArray(array, 0, array.length); } public static char[] toCharArray(final float[] array, final int off, final int len) { return toCharArray(array, off, len, new char[len], 0); } public static char[] toCharArray(final float[] from, final int fromOff, final int len, final char[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (char) from[i]; } return to; } public static char[] toCharArray(final double[] array) { return toCharArray(array, 0, array.length); } public static char[] toCharArray(final double[] array, final int off, final int len) { return toCharArray(array, off, len, new char[len], 0); } public static char[] toCharArray(final double[] from, final int fromOff, final int len, final char[] to, final int toOff) { final int end = fromOff + len; for (int i = fromOff, j = toOff; i < end; i++, j++) { to[j] = (char) from[i]; } return to; } }