NutzCN Logo
问答 解压带中文的文件失败
发布于 3182天前 作者 efraiser 1732 次浏览 复制 上一个帖子 下一个帖子
标签:

解压文件的时候,压缩的文件中有中文的文件存在,解压失败。
代码如下
public Object importXml(@Param("file") TempFile tf, String date, String fileName, String brNo, HttpServletRequest req) {
SysUser user = (SysUser) req.getSession().getAttribute(SystemConstants.SESSION_USER);
File f = tf.getFile();
date = date.substring(0, 6) + (DateUtil.getMonthMaxDays(DateUtil.parse(date, DateUtil.FORMAT_DATE_SHORT)));
String parent;
try {
ZipInputStream Zin = new ZipInputStream(new FileInputStream(f.getCanonicalPath()));// 输入源zip路径
BufferedInputStream Bin = new BufferedInputStream(Zin);
parent = f.getParent() + "\" + date; // 输出路径(文件夹目录)
File Fout = null;
ZipEntry entry;
try {
while ((entry = Zin.getNextEntry()) != null && !entry.isDirectory()) {
Fout = new File(parent, entry.getName());
if (!Fout.exists()) {
(new File(Fout.getParent())).mkdirs();
}
FileOutputStream out = new FileOutputStream(Fout);
BufferedOutputStream Bout = new BufferedOutputStream(out);
int b;
while ((b = Bin.read()) != -1) {
Bout.write(b);
}
Bout.close();
out.close();
}
Bin.close();
Zin.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return requestResult(false, e.getMessage());
}
importData(parent, fileName, date, brNo, f.getCanonicalPath(), user.getUserId());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return requestResult(false, e.getMessage());
}
return requestResult(true, "导入成功");

}

错误信息:
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Reading...
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Upload File info: FilePath=[null],fieldName=[Filename]
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Found a param, name=[Filename] value=[201603.zip]
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Upload File info: FilePath=[null],fieldName=[brNo]
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Found a param, name=[brNo] value=[JSS_TZS_FR_TZNSH]
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Upload File info: FilePath=[null],fieldName=[date]
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Found a param, name=[date] value=[20160301]
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Upload File info: FilePath=[null],fieldName=[fileName]
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Found a param, name=[fileName] value=[201603.zip]
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Upload File info: FilePath=[201603.zip],fieldName=[file]
20:33:14 [DEBUG] org.nutz.mvc.upload.FastUploading - Upload Info: name=201603.zip,content_type=application/octet-stream
java.lang.IllegalArgumentException: MALFORMED
at java.util.zip.ZipCoder.toString(ZipCoder.java:58)
at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:297)
at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:121)
at com.efraiser.dck.action.CkReportAction.importXml(CkReportAction.java:186)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:25)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:40)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:113)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutServlet.service(NutServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)

1 回复

换apache 的压缩库

添加回复
请先登陆
回到顶部