public long copy(final InputStream from, final OutputStream to) throws IOException {
    long count = 0;
    byte[] tmp = mByteArrayPool.get(mTempBufSize);

    try {
      while (true) {
        int read = from.read(tmp, 0, mTempBufSize);
        if (read == -1) {
          return count;
        }
        to.write(tmp, 0, read);
        count += read;
      }
    } finally {
      mByteArrayPool.release(tmp);
    }
  }
Copy all bytes from InputStream to OutputStream.

@param from InputStream
@param to OutputStream
@return number of copied bytes
@throws IOException
fbcore/src/main/java/com/facebook/common/memory/PooledByteStreams.java