import java.io.*;
import javax.swing.JOptionPane;
public class ExpTest {
public static void main(String[] args) {
BufferedReader br = null;
try {
String inputFileLine = JOptionPane.showInputDialog("Insert text file: ");
// Do we have a file to read?
if(!new File(inputFileLine).exists()) {
System.out.println("Can not find " + inputFileLine);
}
System.out.println("Attempting to read " + inputFileLine);
// Do we have a BufferedReader to which "br" is pointing?
// In other words, has "br" been instantiated which means
// is it pointing to an object that has been created with
// the "new" operator? Let's see:
System.out.println("br = " + br);
// Instantiate "br":
br = new BufferedReader(
new InputStreamReader(
new FileInputStream(inputFileLine)));
// Do we have a BufferedReader to which "br" is pointing?
System.out.println("br = " + br);
while((inputFileLine = br.readLine()) != null) {
System.out.println(inputFileLine);
}
br.close();
} catch(IOException e) {
System.out.println("Read error: " + e.getMessage());
}
}
}