I'm getting a NullPointerException in my code. I've use the debugger and traced it to the chooser.getName() line. This is returning a null value to me.
Does anyone have an idea where I went wrong? If it makes a difference, I'm using Linux Mint and the file selected is on a cifs network folder. Perhaps Java is having some problems working with my OS? I can browse the folders fine.
Note, I have not initialized currentFile before this point. Not sure if that would make a difference.
private String currentFile; private boolean setFile() // returns true if there is an error { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter( new FileNameExtensionFilter( "XML files", "xml")); if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return true; currentFile = chooser.getName(); return false; }