public static byte[] readBytes(InputStream in, int count) throws IOException {
    byte[] bytes = new byte[count];
    int offset = 0;
    while (offset < count) {
      int n = in.read(bytes, offset, count - offset);
      if (n < 0) throw new IOException("A premature end of stream");
      offset += n;
    }
    return bytes;
  }
public static byte[] readBytes(InputStream in, int count)