The below program is used to take the input of integers from a text file and plot a XY graph.I have used JFileChooser to select the file. I'm trying to get the complete path of the file. I have created an ActionListener method for the button. When I run it I get the following message:
your getting NullPointer Exceptoion , since your trying to read file outside the actionPerfomred method. in your case exception thrown here , File f = new File(URL); , here URL is always null ...
Place your file reading code inside actionPerformed method , it will work.
also use "File f = new File(file.getAbsolutePath());" to get selected file as stream..