Button Action;
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try {
// TODO add your handling code here:
deneme();
} catch (IOException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}
File reading void;
public void deneme() throws FileNotFoundException, IOException{
try {
FileInputStream file2 = FileInputStream (new File("D:\\Ornek.xls"));
HSSFWorkbook workbook;
workbook = new HSSFWorkbook(file2);
HSSFSheet sheet = workbook.getSheetAt(0);
HSSFRow row1 = sheet.getRow(0);
HSSFCell cellA1 = row1.getCell((short) 0);
String a1Val = cellA1.getStringCellValue();
HSSFCell cellB1 = row1.getCell((short) 1);
String b1Val = cellB1.getStringCellValue();
HSSFCell cellC1 = row1.getCell((short) 2);
String c1Val = cellC1.getStringCellValue();;
System.out.println("A1: " + a1Val);
System.out.println("B1: " + b1Val);
System.out.println("C1: " + c1Val);
}
catch (IOException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null,ex);
}
}
I take below exception when i debug it;
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
Exception throwed by FileInputStream line. Am i missing something ?
Thanks.
-- SOLVED --
Sorry for silly question first:)
FileInputStream file2 = new FileInputStream (new File("D:\\Ornek.xls"));
new
keyword missing at the beginning. Thanks to @dkatzel
I think you are missing the new
key word.
Try this:
FileInputStream file2 = new FileInputStream (new File("D:\\Ornek.xls"));
However that should be a compile error not a runtime error.