SequenceInputStream, PrintStream, RandomAccessFile classes in seek, setLength methods

SequenceInputStream class: It implements InputStream class by concatenating many input streams. Constructors defined by SequenceInputStream class:

SequenceInputStream(InputStream a, InputStream b)

SequenceInputStream(Enumeration strenum)

PrintStream class: PrintStream class is used for handling print and println methods in Constructors defined by PrintStream class:

PrintStream(OutputStream ostr)

PrintStream(OutputStream ostr, boolean flush)

where, flush is used for controlling the flushing of output stream for a new line character.

RandomAccessFile class: It implements DataInput and DataOutput interfaces and is used to wrap random access file. Constructors defined by RandomAccessFile class:

RandomAccessFile(File fileObj, String access) throws FileNotFoundException

RandomAccessFile(String filename, String access) throws FileNotFoundException

Methods defined by RandomAccessFile class:

seek( ) method: It is used to set current position of file pointer.


void seek(long npos) throws IOException

where, npos is used to set the position of file pointer.

setLength( ) method: It is used to set the length of the calling file.


void setLength(long length) throws IOException

Leave a Reply