I know this is an OLD thread, but i"m having the same problem. a Runtime error when trying to "OPEN" a file.
public void actionPerformed( ActionEvent evt)
{
//filterMap.put(evt.getActionCommand(), ((JCheckBox)evt.getSource()).isSelected());
if(evt.getActionCommand().equals("export")){
String file2Read;
file2Read = fileIN.getText();
//file2Read = "NotConverted2.xls";
new BPSepcExporter().BPSReader(file2Read);
}
//If to check if Open button was hit
if(evt.getActionCommand().equals("Open")){
//If to make sure something useful was done
int fIn = BpsFile.showOpenDialog(null);
if(fIn == JFileChooser.APPROVE_OPTION){
File file = BpsFile.getSelectedFile();
fileIN.setText(file.getName());
}
}
}
public void BPSReader(String fileName){
//Input control variable- take from GUI options
List cellDataList = new ArrayList();
try {
//Create a new instance for FileInputStream class
FileInputStream fileInputStream = new FileInputStream(fileName);
// Create a new instance for POIFSFileSystem class
POIFSFileSystem fsFileSystem = new POIFSFileSystem(fileInputStream);
//Create a new instance for HSSFWorkBook Class
HSSFWorkbook workBook = new HSSFWorkbook(fsFileSystem);
HSSFSheet hssfSheet = workBook.getSheetAt(0);
//Iterate the rows and cells of the spreadsheet to get all the datas.
Iterator rowIterator = hssfSheet.rowIterator();
while (rowIterator.hasNext()){
HSSFRow hssfRow = (HSSFRow) rowIterator.next();
Iterator iterator = hssfRow.cellIterator();
List cellTempList = new ArrayList();
while (iterator.hasNext()){
HSSFCell hssfCell = (HSSFCell) iterator.next();
cellTempList.add(hssfCell);
}
cellDataList.add(cellTempList);
}
}
catch (Exception e){
e.printStackTrace();
}
printToConsole(cellDataList);
}
after the exception a bunch of at lines show up, I can post those later if need be. The 2 attached method/constructor methods are the sections where the errors show up. Lines 9 and 27. First in the reader section(27) and then the gui section (9). Now this is reading any file that is not in the same directory as the program, which it was able to do previously.