创建zip压缩文件
public class AAA {
public static void main(String[] args) throws Exception {
File zipFile = new File("D://123.zip");
FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
CheckedOutputStream checkedOutputStream = new CheckedOutputStream(fileOutputStream, new CRC32());
ZipOutputStream zipOutputStream = new ZipOutputStream(checkedOutputStream);
ZipEntry zipEntry = new ZipEntry("99.txt");
zipEntry.setUnixMode(755);
zipOutputStream.putNextEntry(zipEntry);
FileInputStream fileInputStream = new FileInputStream("D://test.txt");
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream, 1024 * 10);
int readed = 0;
byte[] bytes = new byte[1024 * 10];
while ((readed = bufferedInputStream.read(bytes, 0, 1024 * 10)) != -1) {
zipOutputStream.write(bytes, 0, readed);
}
checkedOutputStream.close();
fileInputStream.close();
}
}