public interface DataSource
|Modifier and Type||Interface and Description|
A factory for
|Modifier and Type||Method and Description|
Closes the source.
When the source is open, returns the
Opens the source to read the specified data.
Reads up to
long open(DataSpec dataSpec) throws IOException
dataSpec- Defines the data to be read.
C.LENGTH_UNSET) this value is the resolved length of the request, or
C.LENGTH_UNSETif the length is still unresolved. For all other requests, the value returned will be equal to the request's
IOException- If an error occurs opening the source.
DataSourceExceptioncan be thrown or used as a cause of the thrown exception to specify the reason of the error.
int read(byte buffer, int offset, int readLength) throws IOException
lengthbytes of data and stores them into
buffer, starting at index
length is zero then 0 is returned. Otherwise, if no data is available because the
end of the opened range has been reached, then
C.RESULT_END_OF_INPUT is returned.
Otherwise, the call will block until at least one byte of data has been read and the number of
bytes read is returned.
buffer- The buffer into which the read data should be stored.
offset- The start offset into
bufferat which data should be written.
readLength- The maximum number of bytes to read.
C.RESULT_END_OF_INPUTif no data is available because the end of the opened range has been reached.
IOException- If an error occurs reading from the source.
Urifrom which data is being read. The returned
Uriwill be identical to the one passed
DataSpecunless redirection has occurred. If redirection has occurred, the
Uriafter redirection is returned.
Urifrom which data is being read, or null if the source is not open.