class RedisStreamReader implements Closeable {

  public String readString() throws IOException {
    int noOfBytesRead, newLength;
    byte[] bytes = new byte[0];
    final byte[] tempBytes = new byte[BUFFER_SIZE];
    do {
      noOfBytesRead = inputStream.read(tempBytes);
      newLength = noOfBytesRead
          - (noOfBytesRead > 1 && tempBytes[noOfBytesRead - 2] == RedisBytes.CARRIAGE_RETURN_BYTE
          ? 2 : 0)
          - (noOfBytesRead > 0 && tempBytes[noOfBytesRead - 1] == RedisBytes.CARRIAGE_RETURN_BYTE
          ? 1 : 0);
      byte[] newBytes = new byte[newLength + bytes.length];
      System.arraycopy(bytes, 0, newBytes, 0, bytes.length);
      System.arraycopy(tempBytes, 0, newBytes, bytes.length, newLength);
      bytes = newBytes;
    } while (noOfBytesRead != -1 && newLength == noOfBytesRead);
    return new String(bytes);
  }

  public  RedisStreamReader(InputStream inputStream);

}