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();
public void setLength(long value);
Position Gets or sets the current position within the stream.

public long getPosition();
public void setPosition(long value);

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);

public enum SeekOrigin { FROM_BEGIN(0), FROM_CURRENT(1), FROM_END(2); }

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.

Copyright (c) 2022 Callback Technologies, Inc. - All rights reserved.
CBFS Filter 2020 Java Edition - Version 20.0 [Build 8317]