Home » Java ObjectInputStream readFully() Method with Examples

Java ObjectInputStream readFully() Method with Examples

by Online Tutorials Library

Java ObjectInputStream readFully() Method

The readFully() method of ObjectInputStream class is used to read bytes until all the bytes in the objectinputstream are completely read. It takes 3 parameters as the buffer to which the data is stored , from where to start reading, and how many bytes to read.

Syntax

Parameter

buf – the buffer into which the data is read

off – the start offset into the data array buf

len – the maximum number of bytes to read

Returns

NA

Throws

NullPointerException – If buf is null.

IndexOutOfBoundsException – If off is negative, len is negative, or len is greater than buf.length – off.

EOFException – If end of file is reached.

IOException – If other I/O error has occurred.

Example 1

Output:

welcome to TutorAspire 

Example 2

Output:

welcome  

You may also like