docs: public static byte[] readFully(InputStream in, int size, boolean closeStream) throws IOException {
  
          // create the byte array to hold the data
          byte[] bytes = new byte[size];
  
          // read in the bytes
          int offset = 0;
          
          try {
              int numRead = 0;
              while (offset < size) {
                  numRead = in.read(bytes, offset, size - offset);
                  if (numRead >= 0) {
                      offset += numRead;
                  } else {
                      break;
                  }
              }
          } finally {
              // close the input stream
              if (closeStream) {
                  in.close();
              }
          }
  
          // ensure all the bytes have been read in
          if (offset < bytes.length) {
              throw new IOException("Could not read requested " + size + " bytes from input stream");
          }
  
          return bytes;
      }