public static byte[] getBytesFromStream(InputStream inputStream, int hint) throws IOException {
    // Subclass ByteArrayOutputStream to avoid an extra byte[] allocation and copy
    ByteArrayOutputStream byteOutput =
        new ByteArrayOutputStream(hint) {
          @Override
          public byte[] toByteArray() {
            // Can only use the raw buffer directly if the size is equal to the array we have.
            // Otherwise we have no choice but to copy.
            if (count == buf.length) {
              return buf;
            } else {
              return super.toByteArray();
            }
          }
        };
    ByteStreams.copy(inputStream, byteOutput);
    return byteOutput.toByteArray();
  }
Efficiently fetch the bytes from the InputStream, provided that caller can guess exact numbers
of bytes that can be read from inputStream. Avoids one extra byte[] allocation that
ByteStreams.toByteArray() performs.

@param hint - size of inputStream's content in bytes
fbcore/src/main/java/com/facebook/common/util/StreamUtil.java