Java Zip???Unzip?????

Aspose.Zip API???????????????????????????????????????????????????????????????????????????????????????

?????????

??????????????

1try(fileoutputStream zipfile = new fileoutputStream(datadir + "compressdirectory_out.zip")){
2    try(archive archive = new archive()){
3        file corpus = new file(datadir + "canterburycorpus");
4        archive.createentries(corpus);
5        archive.save(zipfile);
6    }
7} catch(ioException ex){
8    System.out.println(ex);
9}

????????????????

1try(fileinputStream zipfile = new fileinputStream(datadir + "compressdirectory_out.zip")){
2    try(Archive archive = new Archive(zipfile))){
3        archive.extracttodirectory(datadir + "decompressfolder_out");
4    }
5} catch(ioException ex){
6    System.out.println(ex);
7}

????????????????

 1try(fileoutputStream zipfile = new fileoutputStream(datadir + "compressfilesbyfileinfo_out.zip")){
 2    ????fi1 = new file(datadir + "alice29.txt");
 3    ????fi2 = new file(datadir + "fields.c");
 4    try(archive archive = new archive()){
 5        archive.createentry( "alice29.txt"?fi1);
 6        archive.createentry( "fields.c"?fi2);
 7        ArchivesAveOptions options = new archivesaveoptions();
 8        options.SetEncoding(StandardCharsets.us_ascii);
 9        archive.save(zipfile?options);
10    }
11} catch(ioException ex){
12    System.out.println(ex);
13}

????????????????????????

1try(fileinputStream zipfile = new fileinputStream(datadir + "\\ different_password.zip")){
2    try(Archive archive = new Archive(zipfile))){
3        archive.getentries()?get(0).extract(datadir + "alice29_extracted_pa??ss_out.txt"? "first_pass");
4        archive.getEntries()?get(1).extract(datadir + "asyoulik_extracted_pa??ss_out.txt"? "second_pass");
5    }
6} catch(ioException ex){
7    System.out.println(ex);
8}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.