ByteArrayInputStream available Example

ByteArrayInputStream class available example. This example shows you how to use available method.


ByteArrayInputStream class available example. public int available() Returns the number of remaining bytes that can be read (or skipped over) from this input stream.

Here is the code

/**
 * @ # Available.java
 * A class repersenting use to available method 
 * of ByteArrayInputStream class in java.io package
 * version 03 June 2008
 * author Rose India 
 */
import java.io.*;

public class Available {

    public static void main(String args[]) throws Exception {

        byte b[] {12345};
        ByteArrayInputStream baStream = new ByteArrayInputStream(b);

        System.out.println("Byte of data from input stream.");
        //Returns the number of remaining bytes
        while (baStream.available() != 0) {
            //Read  ByteArrayInputStream
            System.out.println(baStream.read());
        }

        //Closing  ByteArrayInputStream
        baStream.close();
    }
}

Output
Byte of data from input stream.
1
2
3
4
5

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

HOME | COPYRIGHT | CONTACT US