code: protected int readFully(InputStream in, byte buffer[])
          throws java.io.IOException {
          for (int i = 0; i < buffer.length; i++) {
              int q = in.read();
              if (q == -1)
                  return i;
              buffer[i] = (byte)q;
          }
          return buffer.length;
      }
docs: This method works around the bizarre semantics of BufferedInputStream's
  read method.