BufferedReader in Java

BufferedReader in Java is used to to read characters, arrays, lines and File Line by line. It also reads text from a character-input stream. A programmer can change the buffer size or can use default size.

Ads

BufferedReader in Java

BufferedReader in Java is used to to read characters, arrays, lines and File Line by line. It also reads text from a character-input stream. A programmer can change the buffer size or can use default size.

BufferedReader class in Java is also used to read the data in buffer. Here we will show how to read line by line data from a file using BufferedReader.

BufferedReader Constructor:

BufferedReader in = new BufferedReader(new FileReader(f));

BufferedReader Methods

  • readLine() - This methods reads line of text
  • read() - This method reads and returns one character
  • read(char[] cbuf, int off, int len) - This method reads character into a portion of an array.
  • skip() - This method skips character.

Video: How to read data from file with BufferedReader in Java?

Following is the example of BufferedReader in Java to read line:

import java.io.*;

public class BufferedReaderDemo {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(
new FileReader("DevFile.txt"));
String devstr;
while ((devstr = br.readLine()) != null) {
System.out.println(devstr);
}
} catch (IOException e) {
}
}
}

Output:

Welcome To Devmanuals
Here you find the good learning stuff.
As well complete coverage on each topics like java, PHP etc.

Advertisements

Share on Google+Share on Google+

BufferedReader in Java

Posted on: May 11, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: BufferedReader in Java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads