View Single Post
  #4 (permalink)  
Old 11-24-2007, 07:21 PM
hardwired hardwired is online now
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
Code:
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()); } } }

Last edited by hardwired : 11-24-2007 at 07:23 PM. Reason: remove tabs
Reply With Quote