public class

PooledByteStreams

extends Object
java.lang.Object
   ↳ com.facebook.common.memory.PooledByteStreams

Class Overview

Helper class for interacting with java streams, similar to guava's ByteSteams. To prevent numerous allocations of temp buffers pool of byte arrays is used.

Summary

Public Constructors
PooledByteStreams(ByteArrayPool byteArrayPool)
PooledByteStreams(ByteArrayPool byteArrayPool, int tempBufSize)
Public Methods
long copy(InputStream from, OutputStream to)
Copy all bytes from InputStream to OutputStream.
long copy(InputStream from, OutputStream to, long bytesToCopy)
Copy at most number of bytes from InputStream to OutputStream.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PooledByteStreams (ByteArrayPool byteArrayPool)

public PooledByteStreams (ByteArrayPool byteArrayPool, int tempBufSize)

Public Methods

public long copy (InputStream from, OutputStream to)

Copy all bytes from InputStream to OutputStream.

Parameters
from InputStream
to OutputStream
Returns
  • number of copied bytes
Throws
IOException

public long copy (InputStream from, OutputStream to, long bytesToCopy)

Copy at most number of bytes from InputStream to OutputStream.

Parameters
from InputStream
to OutputStream
bytesToCopy bytes to copy
Returns
  • number of copied bytes
Throws
IOException