code: public static String readNullTerminatedString(DataInput in) throws IOException, EOFException {
      StringBuilder s = new StringBuilder();
      while (true) {
        int b = in.readByte();
        if (b == 0) {
          break;
        }
        s.append((char) b);
      }
      return s.toString();
    }
docs: Reads a null-terminated string of bytes from the specified input.
  @param in The <code>DataInput</code> to read from.
  @return The <code>String</code> read from the file.
  @throws IOException If an I/O error occurs
  @throws EOFException If the end of the file is reached before a null
  byte is read.