class ByteArrayDataInput extends InputStream implements DataInput, VersionedDataStream {

  @Override
  public String readLine() {
    if (pos >= nBytes) {
      return null;
    }
    // index of the first byte in the line
    int startIdx = pos;
    // index of the last byte in the line
    int lastIdx = -1;
    while (lastIdx == -1) {
      int c = readByteAsInt();
      switch (c) {
        case -1:
          lastIdx = pos;
          break;
        case '\n':
          lastIdx = pos - 1;
          break;
        case '\r':
          lastIdx = pos - 1;
          int c2 = readByteAsInt();
          if (c2 != '\n' && c2 != -1) {
            pos--;
          }
          break;
      }
    }
    @SuppressWarnings("deprecation")
    final String string = new String(bytes, 0, startIdx, lastIdx - startIdx);
    return string;
  }

  public  ByteArrayDataInput();
  public  ByteArrayDataInput(byte[] bytes);
  public  ByteArrayDataInput(byte[] bytes, KnownVersion version);

}