解压zip
来源:互联网 发布:刘义军 知乎 编辑:程序博客网 时间:2024/05/01 13:22
@RequestMapping(method = RequestMethod.POST)
public String doUpload(HttpServletRequest request,
@RequestParam("package_name") MultipartFile mfile)throws Exception {
try {
String dest = Configuration.getInstance().get("upload.basepath");
InputStream input = mfile.getInputStream();
ZipInputStream zipInput = new ZipInputStream(input);
FileOutputStream fileOut;
File file;
int readedBytes = 0;
byte[] buf = new byte[512];
ZipEntry zipEntry;
while( (zipEntry = zipInput.getNextEntry()) != null){
file = new File(dest + "/" + zipEntry.getName());
if(zipEntry.isDirectory()){
file.mkdirs();
}else{
File parent = file.getParentFile();
if(!parent.exists()){
parent.mkdirs();
}
fileOut = new FileOutputStream(file);
while((readedBytes = zipInput.read(buf)) > 0){
fileOut.write(buf, 0, readedBytes);
}
fileOut.close();
}
zipInput.closeEntry();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
public String doUpload(HttpServletRequest request,
@RequestParam("package_name") MultipartFile mfile)throws Exception {
try {
String dest = Configuration.getInstance().get("upload.basepath");
InputStream input = mfile.getInputStream();
ZipInputStream zipInput = new ZipInputStream(input);
FileOutputStream fileOut;
File file;
int readedBytes = 0;
byte[] buf = new byte[512];
ZipEntry zipEntry;
while( (zipEntry = zipInput.getNextEntry()) != null){
file = new File(dest + "/" + zipEntry.getName());
if(zipEntry.isDirectory()){
file.mkdirs();
}else{
File parent = file.getParentFile();
if(!parent.exists()){
parent.mkdirs();
}
fileOut = new FileOutputStream(file);
while((readedBytes = zipInput.read(buf)) > 0){
fileOut.write(buf, 0, readedBytes);
}
fileOut.close();
}
zipInput.closeEntry();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
- ZIP解压
- ZIP解压
- ZIP解压
- zip解压
- 解压zip
- ZIp 解压
- zip解压
- 解压zip
- nodejs zip 解压zip文件
- java 解压zip压缩文件
- Zip文件解压
- JSP解压ZIP压缩文件
- java解压zip源码
- 解压rar,打成zip
- ZIP压缩和解压
- Java解压zip文件
- linux zip 解压/压缩
- zip文件上传下载 解压
- Java 语言的 XPath API
- [leetcode] Remove Duplicates from Sorted Array II
- hdu 2616 Kill the monster(暴搜)
- 安卓环境搭建
- 二叉排序数的总结
- 解压zip
- 数字和的个数
- android自动更新软件版本
- apache负载均衡
- ffmpeg解码jpg并编码成h264
- UVA 1356/ ZOJ 2614 Bridge 弧长积分+二分
- luence之全文检索
- POJ 1903 & ZOJ 2469 & UVA 1326 Jurassic Remains (部分枚举)
- 京东商城发现了一枚Bug