Пример #1
0
 /**
  * Reads a string that consists of a integer denoting the number of bytes, the bytes (including a
  * terminating 0 byte)
  *
  * @return the string
  * @throws IOException if the string could not be read
  */
 protected String readString() throws IOException {
   // read number of bytes
   int bytes = _in.readInt();
   if (bytes <= 0) {
     throw new IOException("Invalid number of string bytes");
   }
   String s;
   if (bytes > 1) {
     s = _in.readUTF(bytes - 1);
   } else {
     s = "";
   }
   // read terminating zero
   _in.readByte();
   return s;
 }
Пример #2
0
 /**
  * @return a null-terminated string read from the input stream
  * @throws IOException if the string could not be read
  */
 protected String readCString() throws IOException {
   return _in.readUTF(-1);
 }