home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Teach Yourself C in 21 Days (6th Edition)
/
STYC216E.ISO
/
mac
/
Examples
/
Day27
/
reading.java
< prev
next >
Wrap
Text File
|
2002-05-26
|
573b
|
23 lines
import java.io.*;
public class ReadTextFile {
public static void main(String args[]) {
String s;
try {
FileReader inFile = new FileReader("c:\\test.txt");
BufferedReader buff = new BufferedReader(inFile);
boolean endOfFile = false;
while (!endOfFile) {
s = buff.readLine();
if (s == null)
endOfFile = true;
else
System.out.println(s);
}
buff.close();
}
catch (IOException e) {
System.out.println("An error occurred: " + e.toString());
}
}
}