ByteArrayInputStream markSupported Example

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


ByteArrayInputStream class markSupported example. public boolean markSupported() Tests if this InputStream supports mark/reset. The markSupported method of ByteArrayInputStream always returns true.

Here is the code

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

public class Mark {

    public static void main(String args[]) throws Exception {
        byte b[] {12345};
        ByteArrayInputStream baStream = new ByteArrayInputStream(b);

        if (baStream.markSupported()) {
            baStream.mark(b.length);
        }
        baStream.reset();
        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