FastStringWriter extends Writer { @Override public void write(final char[] buffer) throws IOException { this.buffer.append(buffer); }  @Override Writer append(final char c); @Override Writer append(final CharSequence csq); @Override Writer append(final CharSequence csq, final int start, final int end); @Override void write(final char[] buffer); @Override void write(final int c); @Override void write(final String str); @Override void write(final String str, final int off, final int len); @Override void write(final char[] buffer, final int off, final int len); @Override void flush(); @Override void close(); @Override String toString();  }
@Test(expected = IndexOutOfBoundsException.class) public void writeCharArrayWithBadOffsetAndLength() throws IOException { Writer writer = new FastStringWriter(); writer.write(new char[]{'h', 'e', 'l', 'l', 'o' }, -1, 3); IOUtils.closeQuietly(writer); }