InputStream, a ByteSource
is not an open, stateful stream for input that can be read and closed. Instead, it is an
immutable supplier of InputStream instances.
ByteSource provides two kinds of methods:
Note: In general, ByteSource is intended to be used for "file-like" sources
that provide streams that are:
size() and read(), will either
block indefinitely or fail if the source creates an infinite stream.
size(), in some
implementations) will prevent further operations from completing as expected.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class | ByteSource.
A char source that reads bytes from this source and decodes them as characters using a charset. |
| private static class | |
| private static class | |
| private static class | |
| private class | ByteSource.
A view of a subsection of the containing byte source. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public CharSource | asCharSource(Charset charset)
Returns a |
| public static ByteSource | Returns: aByteSource containing the concatenated datathe sources to concatenate sources)Concatenates multiple |
| public static ByteSource | Returns: aByteSource containing the concatenated datathe sources to concatenate sources)Concatenates multiple |
| public static ByteSource | Returns: aByteSource containing the concatenated datathe sources to concatenate sources)Concatenates multiple |
| public boolean | contentEquals(ByteSource other)
Checks that the contents of this byte source are equal to the contents of the given byte source. |
| public long | Returns: the number of bytes copiedCopies the contents of this byte source to the given |
| public long | |
| private long | |
| public static ByteSource | |
| public HashCode | hash(HashFunction hashFunction)
Hashes the contents of this byte source using the given hash function. |
| public boolean | |
| public InputStream | |
| public abstract InputStream | |
| public byte[] | |
| public <T extends @Nullable Object> T | read(ByteProcessor<T> processor)
Reads the contents of this byte source using the given |
| public long | size()
Returns the size of this source in bytes, even if doing so requires opening and traversing an entire stream. |
| public Optional | sizeIfKnown()
Returns the size of this source in bytes, if the size can be easily determined without actually opening the data stream. |
| public ByteSource | slice(long offset, long length)
Returns a view of a slice of this byte source that is at most |
| public static ByteSource |