Working with streams of data with Java™
The Stream class lets you examine and manipulate files as streams of binary or character data. Use the createStream method in the Session class to create a new Stream object.
The following methods access the Stream properties:
- getBytes returns an int value containing the size of the stream as number of bytes.
- getCharSet returns a String value containing the character set used by the external data source.
- isEOS returns true if the current position is at the end of the stream.
- isReadOnly returns true if the stream is associated with a read-only file.
- getPosition returns an int value containing the offset from the beginning of the stream in bytes. This int is the position from which the read and readText methods begin. setPosition sets the offset.
Use the write or writeText method to put data into a stream. Use the read or readText method to get data from a stream. Use the truncate method to delete the contents of a stream.
Use the open method to associate a stream with a file and to copy the file contents into the stream. If the file does not exist, the open method creates a new file. Use any of the read or write methods to process the data. Use the close method to release system resources associated with the stream.
Use the getContents method and setContents method to move contents back and forth between a stream and a java.io stream.