0

我尝试阅读 xls(简单试用)但出现错误:

    FileInputStream fi;
    File f = new File("C:\\tdata\\td.xlsx");

    fi = new FileInputStream(f);

    Workbook w = Workbook.getWorkbook(fi);
    Sheet s=w.getSheet(0);
    System.out.println("**********************"+s.getCell(0,1).getContents());



java.io.FileNotFoundException: /C:\tdata\td.xlsx: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:416)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at com.nokia.poicollectiontool.test.Test1.testClick(Test1.java:64)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:177)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1619)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:400)
... 16 more

我不明白实际的问题是什么,因为文件非常存在以及为什么在错误中显示“java.io.FileNotFoundException:/C:\tdata\td.xlsx”(在 C 之前插入 '/')

4

1 回答 1

0

该文件必须存在于设备上。您正在尝试读取您电脑上的文件。这就是为什么它尖叫该文件不存在。例如,您可以使用 adb push commnad 将其放在 sdcard 目录中。

于 2013-05-20T18:02:50.973 回答