Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public byte[] getBytes(char[] buffer, int offset, int count) {
int n = offset + count;
byte[] bytes = new byte[count];
for (int i = offset; i < n; ++i) {
bytes[i] = (byte) (buffer[i] & 255);
bytes[i - offset] = (byte) (buffer[i] & 255);
}
return bytes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ public void testWriteASCIIChar() throws IOException {
new String(ASCII_CHAR_ARRAY).getBytes(StandardCharsets.UTF_8), baos.toByteArray()));
}

public void testWriteArrayWithOffset() throws IOException {
OutputStreamWriter latin1Writer = new OutputStreamWriter(baos, StandardCharsets.ISO_8859_1);
char[] chars = {'a', 'b', 'c', 'd'};
latin1Writer.write(chars, 1, 2);
latin1Writer.close();
assertTrue(Arrays.equals(new byte[] {'b', 'c'}, baos.toByteArray()));
}

public void testWriteArrayUsingNullArray() throws IOException {
final char[] b = null;
try {
Expand Down
Loading