code: public static BigInteger readBigInteger(DataInputStream dis)
              throws IOException {
          short i = dis.readShort();
          if (i < 0)
              throw new IOException("Invalid BigInteger length: " + i);
          byte[] buf = new byte[i];
          dis.readFully(buf);
          return new BigInteger(1, buf);
      }
docs: Read a (reasonably short) BigInteger from a DataInputStream
  
  @param dis the stream to read from
  @return a BigInteger
  @throws IOException I/O exception