jaulib v1.3.0
Jau Support Library (C++, Java, ..)
|
This class represents an abstract byte input stream object. More...
Classes | |
interface | StreamConsumer1 |
Stream consumer using a byte array. More... | |
interface | StreamConsumer2 |
Stream consumer using a direct ByteBuffer. More... | |
Static Public Member Functions | |
static long | read_stream (final ByteInStream in, final byte buffer[], final StreamConsumer1 consumer) |
Synchronous byte array input stream reader using the given StreamConsumer1 . More... | |
static long | read_stream (final ByteInStream in, final ByteBuffer buffer, final StreamConsumer2 consumer) |
Synchronous direct ByteBuffer input stream reader using the given StreamConsumer2 . More... | |
static ByteInStream | to_ByteInStream (final String path_or_uri, final long timeoutMS) |
Parses the given path_or_uri, if it matches a supported protocol, see org.jau.io.UriTk#protocol_supported(String) , but is not a local file, see org.jau.io.UriTk#is_local_file_protocol(String) , ByteInStream_URL is being attempted. More... | |
static ByteInStream | to_ByteInStream (final String path_or_uri) |
Parses the given path_or_uri, if it matches a supported protocol, see org.jau.io.UriTk#protocol_supported(String) , but is not a local file, see org.jau.io.UriTk#is_local_file_protocol(String) , ByteInStream_URL is being attempted. More... | |
static void | print_stats (final String prefix, final long out_bytes_total, final long td_ms) |
This class represents an abstract byte input stream object.
The byte input stream can originate from a local source w/o delay, remote URL like http connection or even from another thread feeding the input buffer.
Both latter asynchronous resources may expose blocking properties in check_available().
Asynchronous resources benefit from knowing their content size, as their check_available() implementation may avoid blocking and waiting for requested bytes available if the stream is already beyond its scope.
One may use error() to detect whether an error has occurred, while end_of_data() not only covered the EOS case but includes error().
Definition at line 48 of file ByteInStreamUtil.java.
|
static |
|
static |
Synchronous byte array input stream reader using the given StreamConsumer1
.
To abort streaming, user may return false
from the given StreamConsumer1#consume(byte[], long, boolean)
.
in | the input byte stream to read from |
buffer | byte buffer passed down to StreamConsumer1#consume(byte[], long, boolean) |
consumer | StreamConsumer consumer for each received heap of bytes, returning true to continue stream of false to abort. |
Definition at line 73 of file ByteInStreamUtil.java.
|
static |
Synchronous direct ByteBuffer input stream reader using the given StreamConsumer2
.
To abort streaming, user may return false
from the given StreamConsumer2#consume(ByteBuffer, boolean)
.
in | the input byte stream to read from |
buffer | byte buffer passed down to StreamConsumer2#consume(ByteBuffer, boolean) |
consumer | StreamConsumer2 consumer for each received heap of bytes, returning true to continue stream of false to abort. |
Definition at line 124 of file ByteInStreamUtil.java.
|
static |
Parses the given path_or_uri, if it matches a supported protocol, see org.jau.io.UriTk#protocol_supported(String)
, but is not a local file, see org.jau.io.UriTk#is_local_file_protocol(String)
, ByteInStream_URL is being attempted.
If the above fails, ByteInStream_File is attempted.
If non of the above leads to a ByteInStream without ByteInStreamUtil#error()
, null is returned.
Method uses a timeout of 20_s for maximum duration to wait for next bytes at ByteInStream_URL#available(long)
path_or_uri | given path or uri for with a ByteInStream instance shall be established. |
ByteInStreamUtil#error()
or nullptr Definition at line 191 of file ByteInStreamUtil.java.
|
static |
Parses the given path_or_uri, if it matches a supported protocol, see org.jau.io.UriTk#protocol_supported(String)
, but is not a local file, see org.jau.io.UriTk#is_local_file_protocol(String)
, ByteInStream_URL is being attempted.
If the above fails, ByteInStream_File is attempted.
If non of the above leads to a ByteInStream without ByteInStreamUtil#error()
, null is returned.
path_or_uri | given path or uri for with a ByteInStream instance shall be established. |
timeoutMS | a timeout in case ByteInStream_URL is being used as maximum duration in milliseconds to wait for next bytes at ByteInStream_URL#available(long) , defaults to 20_s |
ByteInStreamUtil#error()
or nullptr Definition at line 163 of file ByteInStreamUtil.java.