/* * Created on Dec 29, 2005 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package samplecode; import java.io.*; import java.util.*; /** * @author Headley Williamson * Simple code sample that reads a text file line by line and prints it out. * www.greattastingjava.com code licensed under http://creativecommons.org/licenses/by/2.5/ */ public class TextFileReader { public static void main(String[] args) throws Exception { String filepathname ="C:/test.txt"; File f = new File(filepathname); FileReader fr = new FileReader(f); BufferedReader br = new BufferedReader(fr); String line = null; while ((line = br.readLine()) !=null) { System.out.println(line); } } }