On clicking the open button, I am trying to fetch the path of the file, including the file name I opened.
Code:
private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser chooser=new JFileChooser();
String path=chooser.getSelectedFile().getAbsolutePath();//error
System.out.println(path);
}
But I am getting a null pointer exception in the commented (//errror
) line.
Where am I going wrong?