InputStream Marksupported() Example

Tests if this input stream supports the mark and reset methods.


InputStreamclass Marksupported() method example. This example shows you how to use Marksupported() method.This method Tests if this input stream supports the mark and reset methods.

Here is the code:-
/**
 * @Program that Tests if this input stream supports the mark and reset methods.
 * Marksupported.java 
 * Author:-RoseIndia Team
 * Date:-06-Jun-2008
 */
import java.io.*;


public class Marksupported extends InputStream{
     public int read() throws IOException {
        return 0;
    }
    public static void main(String args[]) throws Exception {
        PipedInputStream pis = new PipedInputStream();
        PipedOutputStream o = new PipedOutputStream();
                pis.connect(o);
                 byte b[] {12345};
                 o.write(b);
        System.out.println("Byte of data from input stream.");
                if (pis.markSupported()) {
            pis.mark(b.length);
        }
        boolean e=pis.markSupported();
        System.out.println(e);
        pis.reset();
        System.out.println("Byte of data from input stream.");
        //Returns the number of remaining bytes
        while (pis.available() != 0) {
            //Read InputStream
            System.out.println(pis.read());
        }

        //Closing InputStream
        pis.close();
    }
}

Output of the Program
 Byte of data from input stream.
true
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