You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you need a simple way to zip a single file, you can create a method with something like this:
File zip = new File("tmp/demo.zip");
try (ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(zip.toPath()))) {
// Pass through to create empty zip archive.
}
ZipUtil.addEntry(zip, "tmp/demo.txt", new File("tmp/demo.txt"));
Don't think the above should be added to the library, just figured I'd offer a possible workaround.
//1.create ZipEntrySource array,one or more files add to array.
List<ZipEntrySource> files = new ArrayList<>();
files.add(new FileSource("1.txt", new File("/tmp/1.txt")));
files.add(new FileSource("2.txt", new File("/tmp/2.txt")));
ZipEntrySource[] array = files.toArray(new ZipEntrySource[files.size()]);
//2.pack
ZipUtil.pack(array, new File( "/data/zip/demo.zip"));
i want to such as
ZipUtil.pack(“tmp/demo.txt”), new File("tmp/demo.zip"))
Instead of ZipUtil.pack(“tmp/demo”), new File("tmp/demo.zip"))
can u help me??
The text was updated successfully, but these errors were encountered: