java创建一个空白zip

 

String zipath = localpath+zipname+".zip";

public static void createNewzip(String zipath) throws Exception {
ZipOutputStream zoutput = null;
try {
File file = new File(zipath);
if(!file.exists())
file.createNewFile();
FileOutputStream fOutputStream = new FileOutputStream(file);
zoutput = new ZipOutputStream(fOutputStream);

} catch (Exception e) {
e.printStackTrace();
}finally{
zoutput.closeEntry();
zoutput.close();
}
}

在localpath下面生成一个名为zipname的zip

posted @ 2019-12-05 19:36  景恩  阅读(1433)  评论(0编辑  收藏  举报