poi 文件无法找到

Buhuishangdang Buhuishangdang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
最近做一项目,客户要求一上传excel功能,在网上找了一些资料,有了大概的做法.....

我用的struts做的上传,由于数据可能比较大,所以是先把excel压缩成zip进行上传,上传后再进行解压,解析excel的信息,然后插入库。下面是一些代码



ZipInputStream in = null;
List errors=null;
// FileInputStream(path+fileName));
try {
in = new ZipInputStream(new FileInputStream(path + "\\" + fileName));
ZipEntry entry = new ZipEntry(path + "\\" + fileName);
while ((entry = in.getNextEntry()) != null) {
String entryName = entry.getName();
if (entry.isDirectory()) {
File file1 = new File(path + "\\" + entryName);
file1.mkdirs();
// System.out.println("创建文件夹" + entryName);
} else {
System.out.println(path + "\\" + entryName);
POIFSFileSystem poi = new POIFSFileSystem(new FileInputStream(path+"\\"+fileName)); HSSFWorkbook book = new HSSFWorkbook(poi);
}
}

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
in.closeEntry();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}



文件已经上传成功,而且接压缩也没有问题,路径是对的,可是在去取excel的时候出错了:


D:\work\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\JS\tmp\ko.zip
D:\work\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\JS\tmp\test.xls
java.io.FileNotFoundException: D:\work\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\JS\tmp\test.xls (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at ie.js.tyxxc.service.impl.TyxxcSiteDenizenServiceImpl.isQualified(TyxxcSiteDenizenServiceImpl.java:116)
at ie.js.tyxxc.service.impl.TyxxcSiteDenizenServiceImpl.upload(TyxxcSiteDenizenServiceImpl.java:81)
at ie.js.tyxxc.service.impl.TyxxcSiteDenizenServiceImpl$$FastClassByCGLIB$$c398d221.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:696)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:631)
at ie.js.tyxxc.service.impl.TyxxcSiteDenizenServiceImpl$$EnhancerByCGLIB$$4df71e08.upload(<generated>)
at ie.js.tyxxc.action.TyxxcSiteDenizenAction.parse(TyxxcSiteDenizenAction.java:259)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)


zip中的东西没有实际解压到硬盘中,是不是这个原因而拿不到啊??改怎么解决?
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
Buhuishangdang
Apache 24,915 成员 16,537 内容