RedisOutputStream { void writeBytesCRLF(byte[] bytes) throws IOException { int length = bytes.length; if (length > buffer.length) { flush(); stream.write(bytes); } else { if (length > buffer.length - position) { flush(); } System.arraycopy(bytes, 0, buffer, position, length); position += length; } if (buffer.length - position <= 2) { flush(); } buffer[position++] = '\r'; buffer[position++] = '\n'; } RedisOutputStream(OutputStream stream, int bufferSize);   }
@Test void writeBytesCRLF() throws IOException { stream.writeBytesCRLF(Strings.bytes("12345")); stream.flush(); assertEquals("12345\r\n", decode(output.toByteArray())); }