我尝试阅读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"(inserts'/'在C之前:)
答案 0 :(得分:0)
该文件必须存在于设备上。您正在尝试读取您在电脑上的文件。这就是为什么它尖叫的文件不存在。您可以使用adb push commnad将其放在sdcard目录中。