Creating a zip file with Processing.
in
Programming Questions
•
11 months ago
Hi all - first post
I've managed to get unzipping working just fine using the unzipit library, but am having trouble with getting zipping-up (creating a zip file) working. I've found a couple of java examples like the one below:
Many thanks
Rich
I've managed to get unzipping working just fine using the unzipit library, but am having trouble with getting zipping-up (creating a zip file) working. I've found a couple of java examples like the one below:
- import java.io.*;
- import java.util.zip.*;
- public class ZipCreateExample{ public static void main(String[] args) throws Exception {
- // input file
- FileInputStream in = new FileInputStream("F:/sometxt.txt");
- // out put file
- ZipOutputStream out = new ZipOutputStream(new FileOutputStream("F:/tmp.zip"));
- // name the file inside the zip file
- out.putNextEntry(new ZipEntry("zippedjava.txt"));
- byte[] b = new byte[1024];
- int count;
- while ((count = in.read(b)) > 0) {
- System.out.println();
- out.write(b, 0, count);
- }
- out.close();
- in.close();
- }
- }
Many thanks
Rich
1