Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

FileInputRecordStream

A FileInputRecordStream object represents a file that has been opened for sequential read access. The file is opened implicitly when the object is created (see section "Opening and closing a file").

The FileInputRecordStream class offers methods for reading and skipping records and for closing the file. The method group for positioning is present, but provides no functionality.

The file that is to be opened must already exist in the underlying file system. The createNewFile() method of the RecordFile class must be used to generate a file.

For a file opened for sequential read access a current file position is always defined at which the next read operation is performed. The current file position is defined by the number of the record in accordance with the order of the records in this file, the records of a file being numbered starting with 0. After the file has been opened the current file position is the start of the file.

Opening and closing a file

When a FileInputRecordStream object is constructed, the file specified as RecordFile object is opened in read mode with the specified access method or with the specified access parameters. The file must exist in the underlying file system and the access method must belong to this file system and must be permissible for this file. The user must possess the access rights which permit the file to be read. If a Security Manager is active and its restrictions do not allow the file to be read, an exception is triggered (see section "Security").

If access parameters are specified for opening the file, these are taken into account when the file is opened provided the file parameters do not have priority. After the file has been opened, the parameters are updated with the corresponding values of the opened file.

The close() method closes the file. Subsequently no I/O operations can be performed via this FileInputRecordStream object.

Special features of the DMS file system

Shared update processing (see section "Shared update processing" and section "AccessParameter") of a FileInputRecordStream is possible with the ISAM and UPAM access methods. However, with UPAM only PAM files can be opened in shared update processing. Because the file is opened for reading only, all accesses are made without locks. As a result, no access conflicts can arise. However, it must be expected that another application changes the contents of the record in the meantime.

Methods for reading records

The read method is offered in two variants, one in which the record read is provided as a result in a newly generated Record object, and a second in which a Record object transferred by the calling program as an argument is filled with the data of the record read.

When a record buffer is created, it has precisely the same size as the data read. If the calling program provides the Record object, it must ensure that the record buffer is large enough to contain the data of the record to be read. If the specified record buffer is too small to contain all the data, an exception is triggered and no data is transferred.

The read() methods read the record at the current file position. The current file position is subsequently incremented by one, in other words the next record is automatically positioned on.

The skip() method enables the specified number of records in the file to be skipped. It may be the case that it is not possible to skip exactly the number of records specified (for example if there are no longer enough records in the file). The return value of skip() specifies the actual number of records that are skipped.

The available() method returns the minimum number of records that can be read without blocking. But even the result null, which is often returned if it is impossible or difficult to determine whether a read attempt leads to a wait state (of the thread), does not justify the assumption that the next call of read() or skip() will actually lead to such a wait state.

Methods for positioning

The markSupported() method provides information on whether marking or repositioning is supported for this file. As with the java.io.FileInputStream class, positioning is currently not supported for objects of this class, in other words this method always returns false.

The mark() method is present, but has no function.
Calling reset() results in an exception as this functionality is currently not supported.