Reader MarkSupported() Example

Tells whether this stream supports the mark() operation.


Reader class MarkSupported() method example. This example shows you how to use MarkSupported() method.This method Tells whether this stream supports the mark() operation.

Here is the code:-

/**
 * @Program that Tells whether this stream supports the mark() operation.
 * MarkSupported.java 
 * Author:-RoseIndia Team
 * Date:-5-jun-2008
 */
import java.io.*;

public class MarkSupported {
public static void main(String[] args)throws IOException {
 // Create a new StringReader.
        String s = "Roseindia";
        StringReader r = new StringReader(s);
        char firstLetter = (charr.read();
        // Set the mark.
        if (r.markSupported()) {
            r.mark(0);
        }
        boolean b=r.markSupported();
        System.out.println("This stream supports the mark() operation: "+b);
        // Continue reading from the string.
        char secondLetter = (charr.read();
        char thirdLetter = (charr.read();
        char fourthLetter = (charr.read();
        char fifthLetter = (charr.read();
        char SixthLetter = (charr.read();
        char SeventhLetter = (charr.read();
        char eightthLetter = (charr.read();
        char ninthLetter = (charr.read();
        // Reset the StringReader.
        r.reset();
        // Get the first character read after the reset.
        char nextLetter = (charr.read();
        System.out.println("The next letter after reset is: " +
                nextLetter);
        // Close the StringReader.
        r.close();
    }
    }



Output of the Program
 This stream supports the mark() operation: true
The next letter after reset is: o

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

HOME | COPYRIGHT | CONTACT US