import java.io.*;
public class ReadingAFile {
public static void main(String[] args) {
String[] strs = new String[20];
int count = 0;
BufferedReader br = null;
try {
File file = new File("readingAFile.txt");
br = new BufferedReader(
new InputStreamReader(
new FileInputStream(file)));
String line;
while((line = br.readLine()) != null) {
strs[count++] = line;
}
br.close();
} catch(IOException e) {
System.out.println("read error: " + e.getMessage());
}
for(int j = 0; j < count; j++) {
System.out.println(strs[j]);
}
}
}
readingAFile.txt
Waking Ned Devine
No Country for Old Men
The Postman
Clearcut
The Princess Bride