tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Java > IO > Read Text File

Read Text File 

The following example shows how to read a text file using BufferedReader.

File Name  :  
com/bethecoder/tutorials/io/ReadTextFile.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.io;

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

public class ReadTextFile {

  /**
   @param args
   */
  public static void main(String[] args) {

    try {
      BufferedReader reader = new BufferedReader(new FileReader("C:\\abc.txt"));
      String line = null;
      
      while ((line = reader.readLine()) != null) {
        System.out.println(line);
      }
      
    catch (IOException e) {
      e.printStackTrace();
    }
  }

}
   

It gives the following output,
Hello World 
WriteTextFile Example



 
  


  
bl  br