private final class ByteSource.SlicedByteSource extends ByteSource
Modifier and Type | Field and Description |
---|---|
private long |
length |
private long |
offset |
Modifier | Constructor and Description |
---|---|
private |
SlicedByteSource(long offset,
long length) |
Modifier and Type | Method and Description |
---|---|
boolean |
isEmpty()
Returns whether the source has zero bytes.
|
java.io.InputStream |
openBufferedStream()
Opens a new buffered
InputStream for reading from this source. |
java.io.InputStream |
openStream()
Opens a new
InputStream for reading from this source. |
ByteSource |
slice(long offset,
long length)
Returns a view of a slice of this byte source that is at most
length bytes long
starting at the given offset . |
private java.io.InputStream |
sliceStream(java.io.InputStream in) |
java.lang.String |
toString() |
asCharSource, concat, concat, concat, contentEquals, copyTo, copyTo, empty, hash, read, read, size, wrap
public java.io.InputStream openStream() throws java.io.IOException
ByteSource
InputStream
for reading from this source. This method should return a new,
independent stream each time it is called.
The caller is responsible for ensuring that the returned stream is closed.
openStream
in class ByteSource
java.io.IOException
- if an I/O error occurs in the process of opening the streampublic java.io.InputStream openBufferedStream() throws java.io.IOException
ByteSource
InputStream
for reading from this source. The returned stream is
not required to be a BufferedInputStream
in order to allow implementations to simply
delegate to ByteSource.openStream()
when the stream returned by that method does not benefit
from additional buffering (for example, a ByteArrayInputStream
). This method should
return a new, independent stream each time it is called.
The caller is responsible for ensuring that the returned stream is closed.
openBufferedStream
in class ByteSource
java.io.IOException
- if an I/O error occurs in the process of opening the streamprivate java.io.InputStream sliceStream(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public ByteSource slice(long offset, long length)
ByteSource
length
bytes long
starting at the given offset
.slice
in class ByteSource
public boolean isEmpty() throws java.io.IOException
ByteSource
isEmpty
in class ByteSource
java.io.IOException
- if an I/O error occurspublic java.lang.String toString()
toString
in class java.lang.Object