public class DataByteArraySource extends Object implements DataSource
 A DataSource implementation based on an array.
 
| Constructor and Description | 
|---|
DataByteArraySource(byte[] data,
                   String name,
                   boolean closeable,
                   boolean resettable)
 Creates a source. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
close()  | 
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. 
 | 
public DataByteArraySource(byte[] data,
                           String name,
                           boolean closeable,
                           boolean resettable)
Creates a source.
data - The array.name - The name of the source.closeable - The flag if the close() method will close the stream.resettable - The flag if the reset() method will be supported.IllegalArgumentException - If any of the parameters are null.public String getName()
DataSourceReturns the name of the source.
This name is used e.g. for detail messages of exceptions.
getName in interface DataSourcepublic long getLength()
DataSourceReturns the length of the data which can be read from the source in bytes.
getLength in interface DataSource-1, if the length is unknown.public boolean isResettable()
DataSourceReturns the flag if the source can be reseted.
isResettable in interface DataSourcetrue, if the source can be reseted,
         false otherwise.DataSource.reset()public void reset()
           throws IOException
DataSourceResets 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
 DataSource.getInputStream() method will return a new InputStream
 which reads the source from the beginning again.
 
reset in interface DataSourceIOException - If an I/O error occurs or if the source doesn't support a
             reset.DataSource.isResettable()public InputStream getInputStream() throws IOException
DataSourceReturns 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 DataSource.reset() method was successfully called the method will
 return a different InputStream.
 
getInputStream in interface DataSourceIOException - If an I/O error occurs.public void close()
           throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2015–2019. All rights reserved.