ByteArrayWriter extends Writer { @Override public void write(char[] cbuf, int off, int len) { ensureCapacity(position + len); if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } buffer.write(cbuf, off, len, position); position += len; } ByteArrayWriter();  ByteArrayWriter(int initialSize);  ByteArrayWriter(ByteArray buffer); @Override void close(); @Override void flush(); @Override void write(char[] cbuf, int off, int len); ByteArray getBuffer(); int getTotalBytesWritten(); void write(int c); void write(String str); void write(String str, int off, int len);  }
@Test public void testWriteCharArrayIntInt() throws IOException { ByteArray ba = new ByteArray(100, ByteArray.EBCDIC_CHARSET_NAME); write(ba); ba = new ByteArray(100); write(ba); }