Java Zip
ZipOutputStream out=new ZipOutputStream(new FileOutputStream("E:/Download/Test.zip"));ZipEntry entry1 = new ZipEntry("Test1.txt"); out.putNextEntry(entry1); InputStream is1 = new FileInputStream("E:/Download/JavaZip/Test1.txt"); int len1 = 0; while ((len1 = is1.read()) != -1) out.write(len1); is1.close(); ZipEntry entry2 = new ZipEntry("Test2.txt"); out.putNextEntry(entry2); InputStream is2 = new FileInputStream("E:/Download/JavaZip/Test2.txt"); int len2 = 0; while ((len2 = is2.read()) != -1) out.write(len2); is2.close(); out.close();
页:
[1]