CBFSFilterStream Type
Syntax
cbfsfilter.CBFSFilterStream
Remarks
The CBFSFilterStream type is returned by some of the CBFilter class's methods. All stream types in CBFS Filter share a common API, documented below.
This type provides a custom streaming API with full read, write, and seek functionality; and implements Closable in order to be compatible with the try-with-resources pattern. To interact with a stream via conventional Java streaming APIs, use the GetInputStream and GetOutputStream methods to obtain an InputStream or OutputStream object.
Properties | |
Length |
Gets or sets the length of the stream, in bytes.
public long getLength(); |
Position |
Gets or sets the current position within the stream.
public long getPosition(); |
Methods | |
Close |
Closes the stream, releasing all resources currently allocated for it.
public void close(); Closing a CBFSFilterStream instance also closes all Java stream objects that have been created using its GetInputStream and GetOutputStream methods. |
Flush |
Forces all data held by the stream's buffers to be written out to storage.
public void flush(); |
GetInputStream |
Creates a standard Java InputStream tied to the current CBFSFilterStream instance.
public InputStream getInputStream(); When an InputStream obtained from this method is closed, the CBFSFilterStream instance that created it is also closed (which, as Close describes, causes all other Java stream objects tied to that CBFSFilterStream instance to be closed as well). |
GetOutputStream |
Creates a standard Java OutputStream tied to the current CBFSFilterStream instance.
public OutputStream getOutputStream(); When an OutputStream obtained from this method is closed, the CBFSFilterStream instance that created it is also closed (which, as Close describes, causes all other Java stream objects tied to that CBFSFilterStream instance to be closed as well). |
Read |
Reads a sequence of bytes from the stream and advances the current position within the stream by the number of bytes read.
public byte[] read(int count); Count specifies the number of bytes that should be read from the stream. Returns a byte array containing the data read from the stream. The length of the returned byte array may be less than Count if that many bytes are not currently available, or may be 0 if the end of the stream has been reached. |
Seek |
Sets the current position within the stream based on a particular point of origin.
public long seek(long offset, CBFSFilterStream.SeekOrigin origin); Offset specifies the offset in the stream to seek to, relative to Origin. SeekOrigin is an enum declared within the CBFSFilterStream class as shown above. Returns the new position within the stream. |
Write |
Writes a sequence of bytes to the stream and advances the current position within the stream by the number of bytes written.
public int write(byte[] data); Data specifies the data to write to the stream. Returns the total number of bytes written to the stream. |