【发布时间】:2014-08-20 13:44:48
【问题描述】:
按钮操作;
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);
}
}
文件读取无效;
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);
}
}
调试时出现以下异常;
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
FileInputStream 行抛出异常。我错过了什么吗?
谢谢。
-- 已解决--
对不起,首先提出愚蠢的问题:)
FileInputStream file2 = new FileInputStream (new File("D:\\Ornek.xls"));
new 开头缺少关键字。感谢@dkatzel
【问题讨论】:
-
哪一行确切地引发了该异常?请发布堆栈跟踪。
-
你的意思是
new FileInputStream(new File etc)吗? -
相关问题 - 如果您有 File 对象,pass that straight to Apache POI, do not go via an InputStream。和clearly explained in the docs一样,直接使用文件的内存占用少得多,而且速度更快!
标签: java apache-poi fileinputstream