RedisInputStream { String readSimpleString() throws IOException { var builder = new StringBuilder(); while (true) { fill(); byte value1 = buffer[position++]; if (value1 == '\r') { fill(); byte value2 = buffer[position++]; if (value2 == '\n') { break; } builder.append((char) value1); builder.append((char) value2); } else { builder.append((char) value1); } } String response = builder.toString(); if (response.isEmpty()) { throw new IOException("simple string must not be empty"); } return response; } RedisInputStream(InputStream stream);   }
@Test void readSimpleString() throws IOException { RedisInputStream stream = new RedisInputStream(new ByteArrayInputStream(Strings.bytes("line1\rline2\r\n"))); String message = stream.readSimpleString(); assertEquals("line1\rline2", message); }