Reader Read() Example

Reads a single character.


Reader class Read() method example. This example shows you how to use Read() method.This method Reads a single character.

Here is the code:-

/**
 * @Program that Reads a single character.
 * Read.java 
 * Author:-RoseIndia Team
 * Date:-5-jun-2008
 */
import java.io.*;

public class Read {

    public static void main(String[] argsthrows IOException {
        // Create a new StringReader.
        String s = "Roseindia";
        StringReader r = new StringReader(s);
        for (int i = 0; i < s.length(); i++) {
            if (r.ready()) {
                // Reads a single character.
                char charRead = (charr.read();
                System.out.println(charRead);
            else {
                break;
            }
        }
r.close();
    }
}

Output of the Program
R
o
s
e
i
n
d
i
a

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

HOME | COPYRIGHT | CONTACT US