728x90 AdSpace

Wednesday, 2 October 2013

Read File using BufferedReader

In this tutorials we are going to see how to read file using BufferedReader.
Create project called JavaMisc.
Create package called com.javatutorialscorner.io Create java class called FileReaderExample under com.javatutorialscorner.io package.
package com.javatutorialscorner.io;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class FileReaderExample {

public static void main(String[] args) {

FileReader fr = null;

BufferedReader br = null;
try {
fr = new FileReader("C:\\jtc\\javatutorialscorner.txt");
br = new BufferedReader(fr);
String tempLine;

while ((tempLine = br.readLine()) != null) {
} catch (IOException e) {
// TODO Auto-generated catch block
}finally {

try {
if (br != null) {
} catch (IOException e) {
// TODO Auto-generated catch block



Now run the program see the following output in console.
this is test file created by java tutorials corner
This content read from input file
Annamalai Thangaraj

Annamalai is working as Technical Lead in Leading Telecom company with 5+ years experience in Identity and Access Management , Telecom and Networks, BigData, Java, Spring, Struts, Hibernate, AngularJS, and Enterprise Web Application Development.

Website: Java Tutorials Corner

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments


Post a Comment

Item Reviewed: Read File using BufferedReader Rating: 5 Reviewed By: Annamalai Thangaraj