/** * We have decided for our use-case to ignore offset and length and always * write the whole char array */ @Override public void write(char[] cbuf, int off, int len) throws IOException { String str = String.valueOf(cbuf); write(str, off, len); }
/** * We have decided for our use-case to ignore offset and length and always * write the whole char array */ @Override public void write(char[] cbuf, int off, int len) throws IOException { String str = String.valueOf(cbuf); write(str, off, len); }
@Test public void fillLinesWithCharArraysWithIgnoredOffsetAndLength() throws IOException { LineWriter lines = new LineWriter(); char[] firstLine = { 'f', 'i', 'r', 's', 't', ' ', 'l', 'i', 'n', 'e' }; char[] secondLine = { 's', 'e', 'c', 'o', 'n', 'd', ' ', 'l', 'i', 'n', 'e' }; lines.write(firstLine, 5, 100); lines.write(secondLine, 5, 110); lines.close(); assertThat(lines.getLines(), contains("first line", "second line")); } }
@Test public void fillLinesWithCharArrays() throws IOException { LineWriter lines = new LineWriter(); char[] firstLine = { 'f', 'i', 'r', 's', 't', ' ', 'l', 'i', 'n', 'e' }; char[] secondLine = { 's', 'e', 'c', 'o', 'n', 'd', ' ', 'l', 'i', 'n', 'e' }; lines.write(firstLine, 0, 10); lines.write(secondLine, 0, 11); lines.close(); assertThat(lines.getLines(), contains("first line", "second line")); }