BufferedReaderClass in Java(I/O Stream)
BufferedReaderClass in Java(I/O Stream)
Using java BufferedReader class we can to read input from either keyboard or existing file.This BufferedReader class is used to read the character from charecter input stream.
There are three input stream in java (IO stream)
System.in,System.out,system.err
InputStreamReader → read bytes and decoded to charecter set
File Reader —> used to read data from existing file
This is done with the help of system.in(standard I/Ostream)
The buffered data is read using the BufferedReader class method
Each class has many methods.To invoke this method
object must be created.When reading data using filereader class,
if the file does not exist, an exception is raised.So when using the
bufferedreader class, the program should include IOException
BufferedReader class available in io package.If you want to
implement methods in the BufferedReader class, you have to import io package
Methods available in bufferedreader class
Reads charecter/string
read()--->read single charecter
readLine()--->reads multiple charecter or string
How to implement this method
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(ir);
String str=br.readLine();
Comments
Post a Comment