public interface DataSource extends Closeable
The source for reading data.
Modifier and Type | Method and Description |
---|---|
InputStream |
getInputStream()
Returns a stream for reading the data.
|
long |
getLength()
Returns the length of the data which can be read from the source in
bytes.
|
String |
getName()
Returns the name of the source.
|
boolean |
isResettable()
Returns the flag if the source can be reseted.
|
void |
reset()
Resets the source.
|
String getName()
Returns the name of the source.
This name is used e.g. for detail messages of exceptions.
long getLength()
Returns the length of the data which can be read from the source in bytes.
-1
, if the length is unknown.boolean isResettable()
Returns the flag if the source can be reseted.
true
, if the source can be reseted,
false
otherwise.reset()
void reset() throws IOException
Resets the source.
If the source can't be reseted an IOException
will be thrown.
If the source can be reseted the next call of the
getInputStream()
method will return a new InputStream
which reads the source from the beginning again.
IOException
- If an I/O error occurs or if the source doesn't support a
reset.isResettable()
InputStream getInputStream() throws IOException
Returns a stream for reading the data.
The method will always return the same InputStream
if the source
is still open. If the InputStream.close()
method is called the
source will behave the same as the Closeable.close()
method was called.
If the reset()
method was successfully called the method will
return a different InputStream
.
IOException
- If an I/O error occurs.Copyright © 2015–2019. All rights reserved.