Abbey Workshop | ||||||||||
This sample Java class demonstrates how to read a simple text file one line at a time. First, open a FileReader, then filter this through a BufferedReader to read the file one line at a time. Detailed comments are included with the code below.
Download source for: ReadFile.java
Here is the sample output from the program
C:> java ReadFile Temp.java
1: import java.lang.*;
2:
3: class Temp{
4: public static void main(String[] args) {
5: System.out.println("This is a template file");
6: }
7: }
C:> java ReadFile
Usage: java ReadFile filename
Copyright © Abbey Workshop 2006