创建压缩文件,并添加压缩的内容

public static void saveZipFile(){
try {
ZipOutputStream zipout = new ZipOutputStream(new FileOutputStream("E:\\wangjing.zip"));
zipout.setEncoding("utf8");
zipout.putNextEntry(new ZipEntry("aaa/aa.json"));//往压缩包里添加aaa目上录和aaa目录下的aa.json,并将helloworld写入aaa.json
zipout.write("helloworld".getBytes());
zipout.close();
} catch (Exception e) {
e.printStackTrace();
}
}
posted @ 2017-10-09 18:02  奋小斗g  阅读(310)  评论(0编辑  收藏  举报