//Program to read character by character from the buffer
Description
This program demonstrates the concept of BufferedReader in Java. The program declares an instance br of BufferedReader class. The characters entered by the user is read into the variable c using the read() function, each time printing the character to the output screen. This procedure continues until the entered character is not 'q'.
Program
import java.io.*; public class BReader { public static void main(String s[])throws Exception {char c; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Type in some characters end with q"); do { c=(char)br.read(); System.out.print(c); } while(c!='q'); } }
Output
Reading characters using buffer |
No comments:
Post a Comment