Java BufferedInputStream available() Example

BufferedInputStream class available() method example. This example shows you how to use available() method.


Syntax is : public int available() throws IOException
This method returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.

Here is the code.
/**
 * @(#) AvailableBufferedInputStream.java
 * A class representing use of method available() of BufferedInputStream class in 
 java.io Package.
 * @Version  03-May-2008
 @author   Rose India Team
 */
import java.io.*;
public class AvailableBufferedInputStream {
     public static void main(String[] argsthrows IOException{

       /* Construct an buffer input stream using some String value.
        This is deprecated method in java api 1.6. */
         StringBufferInputStream obj = new StringBufferInputStream("MAHENDRA")

     // Construct the buffer using the buffer input stream obj.
         BufferedInputStream bin = new BufferedInputStream(obj);

         // available() method call. 
         int byteCount = bin.available();
         System.out.print("The number of bytes that can be read : "+byteCount);
   }
}

Output of the program.
The number of bytes that can be read : 8

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US