The available() method of PushbackInputStream class in Java is used to find the number of bytes that can be read from the input stream without blocking. It returns the estimated value of this number of bytes. It may be blocked by the next invocation of a method for the same input stream.
public int available() throws IOException
Overrides: This method overrides the available() method of FilterInputStream class.
Parameters: This method does not accept any parameter.
Return value: This method returns the number of bytes that can be read from the input stream without blocking.
Exceptions: This method throws IOException if the input stream is closed by calling the close() method of the same class or an I/O error occurs.
Below programs illustrate available() method of PushbackInputStream class in IO package:
Total Bytes : 5
Total Bytes : 13
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.