Hi there. I'm a newbie and am having what I'm sure is an easily corrected issue. I am using JFileChooser in one class to select a file that I would like to to have passed onto another class for file reading.
private String selectFileOpen(String title) {
JFileChooser fileopen = new JFileChooser(fileChooserString);
FileFilter filter = new FileNameExtensionFilter("Text files", "txt");
fileopen.addChoosableFileFilter(filter);
int returnVal = fileopen.showDialog(null, title);
//Valid file loaded
if (returnVal == JFileChooser.APPROVE_OPTION) {
File f = fileopen.getSelectedFile();
fileChooserString = f.getPath();
return f.getPath();
}
return "";
In the class I am trying to call the string into i am using the code
FileInputStream fstream = new FileInputStream(i.selectFileOpen.f.getPath());
I am apparently not calling it correctly. Any help?
Thanks