ByteArray implements Serializable, Cloneable { public char[] readAsCharArray(int displacement, int length) { char[] chars = new char[length]; for (int i = 0; i < length; i++) { chars[i] = readAsChar(displacement + i); } return chars; } ByteArray(int size);  ByteArray(int size, String encoding);  ByteArray(int size, ByteOrder order);  ByteArray(int size, String encoding, ByteOrder order);  ByteArray(byte[] array);  ByteArray(byte[] array, ByteOrder order);  ByteArray(byte[] array, String encoding);  ByteArray(byte[] array, String encoding, ByteOrder order);  ByteArray(ByteArray byteArray);  ByteArray(ByteBuffer buffer);  ByteArray(ByteBuffer buffer, String encoding); Object clone(); ByteArray slice(int displacement, int length); ByteArray duplicate(); boolean testBit(int displacement, byte mask); ByteArray setBit(int displacement, byte mask); ByteArray setBit(int displacement, byte mask, boolean b); ByteArray clearBit(int displacement, byte mask); byte[] read(int displacement, int length); int read(int displacement, byte[] bytes); int read(int displacement, byte[] bytes, int offset, int length); byte readAsByte(int displacement); ByteArray readAsByteArray(int displacement, int length); char readAsChar(int displacement); char[] readAsCharArray(int displacement, int length); int read(int displacement, char[] chars); int read(int displacement, char[] chars, int offset, int length); String readAsString(); String readAsString(int displacement); String readAsString(int displacement, int length); String readAsString(int displacement, int length, boolean nts); float readAsFloat(int displacement); double readAsDouble(int displacement); short readAsShort(int displacement); int readAsInt(int displacement); long readAsLong(int displacement); String readPns(int displacement, int length); String readPns(int displacement, int length, boolean convertAtoF); ByteArray fill(); ByteArray fill(byte filler); ByteArray fill(byte filler, int displacement, int length); ByteArray write(char[] chars, int displacement); ByteArray write(char[] chars, int offset, int length, int displacement); ByteArray write(ByteArray byteArray, int displacement, int length); ByteArray write(ByteArray byteArray, int displacement); ByteArray write(byte[] bytes, int displacement); ByteArray write(byte[] bytes, int offset, int length, int displacement); ByteArray write(String s, int displacement); ByteArray write(String s, int displacement, int length); ByteArray write(String s, int displacement, int length, boolean nts); ByteArray write(short s, int displacement); ByteArray write(char c, int displacement); ByteArray write(byte b, int displacement); ByteArray write(int i, int displacement); ByteArray write(long i, int displacement); ByteArray write(float f, int displacement); ByteArray write(double d, int displacement); ByteArray writeAsPs(String s, int displacement, int length); ByteArray writeAsPns(String s, int displacement, int length); ByteArray writeAsPns(String s, int displacement, int length,
                                char filler); static byte getSpaceFiller(String encoding); static ByteArray valueOf(String string); @Override boolean equals(Object anObject); static boolean equalTo(ByteArray a, ByteArray b); boolean equalSame(byte b); boolean equalSame(byte b, int displacement, int length); int getLength(); boolean hasArray(); UnderlyingArray getArray(); byte[] getBytes(); @Deprecated byte[] getByteArray(); ByteArray setEncoding(String encoding); String getEncoding(); ByteArray setOrder(ByteOrder order); ByteOrder getOrder(); ByteBuffer getBuffer(); static final String ASCII_CHARSET_NAME; static final String EBCDIC_CHARSET_NAME; }
@Test public void testReadAsCharArray() { byteArray = new ByteArray(20, ByteArray.EBCDIC_CHARSET_NAME); byteArray.write("TEST", 0); char[] value = byteArray.readAsCharArray(0, 4); assertTrue(value.length == 4); char[] test = new String("TEST").toCharArray(); ByteArrayDumpFormatter.dumpByteArray("TEST", byteArray.getArray().value); for (int i = 0; i < test.length; i++) { assertTrue(test[i] == (value[i] & 0x00ff)); } }