??? ?????????? ? ??????????? ????? ? Java
?????
??? ?????? ?????? ???, ??? ?????????? ????? ????? ZIP, ????????? ????????? ??????, ???????????? Java API ? ?????? ????. ?? ???????, ??? ?????????? ??? ??????? ???? ??? ????????? ??????, ? ????? ??? ZIP -????? ????????????. ?? ????? ???????, ??? ????????????????? ??? ??????????? ?????.
ZIP ??? ?????? ?????? ? ?????? Java ? ???????????? ??? UNZIP ? Java
Aspose.zip API ????????? ??? ??????? ? ????????????????? ?????, ?? ?????????? ? ??????? ????????? ??????. ? ???? ?????? ???????? ?????? ? ?????, ? ????? ? ??????????? ??????? ??????.
?????? ??????
?????? ?????????? ?????
????: ?????? ?????????? ????? ? java
- ???????? File Wouting Stream ? ???????? ?????? ?????? ????????? ZIP -?????.
- ??????? File Fount Stream ????? ?????? ??? ??????.
- ???????? ????????? Archive ????? ? ?????????? ??? ????????? ArchiveEntrySettings ??????.
- ???????? ???? ??????, ????????? ?? ???? 2, ????????? ????? archive.createEntry.
- ???????????? ???? ??????, ????????? ????? archive.save ? ????????? ??? ????? ?????, ????????? ?? ???? 1.
1try (fileOutputStream ZipFile = new FileOutputStream (datadir + "compresssinglefile_out.zip")) {
2 // ???? ??? ?????????? ? ?????
3 try (fileInputStream Source1 = new FileInputStream (datadir + "alice29.txt")) {
4 Try (Archive Archive = ????? Archive (New ArchiveEntrySettings ())) {
5 Archive.createEntry ("alice29.txt", Source1);
6 Archive.save (Zipfile);
7 }
8 }
9} catch (ioException ex) {
10 System.out.println (Ex);
11}?????? ?????????? ??????
????: ?????? ?????????? ?????? ? java
- ???????? ????? ????? ? ???????? ?????? ?????? ????????? ZIP -?????.
- ???????? ????? ????? ??????? ????? ?????? ??? ??????.
- ???????? ????? ????? ??????? ????? ?????? ??? ??????.
- ???????? ????????? Archive ??????.
- ???????? ????? ??????, ????????? ?? ???? 2 ? ???? 3, ????????? ????? archive.createEntry.
- ???????? ????????? ArchivesaveOptions ?????.
- ???????????? ????? ??????, ????????? ????? archive.save ? ????????? ??? ????? ?????, ????????? ?? ???? 1, ? ????????? ArchivesaveOptions, ????????? ?? ???? ????.
1try (fileOutputStream ZipFile = new FileOutputStream (datadir + "compresssinglefile_out.zip")) {
2 try (fileInputStream Source1 = new FileInputStream (datadir + "alice29.txt")) {
3 try (fileInputStream Source2 = new FileInputStream (datadir + "asyoulik.txt")) {
4 Try (Archive Archive = ????? Archive (New ArchiveEntrySettings ())) {
5 Archive.createEntry ("alice29.txt", Source1);
6 Archive.createEntry ("asyoulik.txt", Source2);
7 ArchivesaveOptions Options = new ArchivesaveOptions ();
8 Options.SetencoDing (StandardCharsets.us_ascii);
9 Options.SetArchiveComment (�???? ??? ????? ?? ???????????????? ???????�);
10 archive.save (zipfile, ?????);
11 }
12 }
13 }
14} catch (ioException ex) {
15 System.out.println (Ex);
16}?????? ?????? ? ??????? ?????????? ? ?????
????: ?????? ?????? ? ??????? ????? ? Java
- ???????? ???????? ????? ????? ? ???????? ?????? ?????? ????????? ZIP -?????.
- ??????? ???? ?????? ?????? ??????? ????? ?????? ??? ??????.
- Create File ?????? ?????? ??????? ????? ?????? ??? ??????.
- ???????? ????????? Archive ??????.
- ???????? ????? ??????, ????????? ?? ???? 2 ? ???? 3, ????????? ????? archive.createEntry.
- ???????? ????????? ArchivesaveOptions ??????.
- ???????????? ????? ??????, ????????? ????? archive.save ? ????????? ??? ????? ?????, ????????? ?? ???? 1, ? ????????? ArchivesaveOptions, ????????? ?? ???? ????.
1try (fileOutputStream ZipFile = new FileOutputStream (datadir + "compressfilesbyfileinfo_out.zip")) {
2 File fi1 = ????? ???? (datadir + "alice29.txt");
3 File fi2 = ????? ???? (datadir + "fields.c");
4 ?????????? (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, ?????);
10 }
11} catch (ioException ????????????) {
12 System.out.println (Ex);
13}???????? ?????? ? ??????? ??? ??????
????: ???????? ?????? ? ??????? ??? ?????? ? ?????????????? java
- ???????? ???????? ????? ????? ? ???????? ?????? ?????? ????????? ZIP -?????.
- ???????? ???? ??????? ??? ???????? ????? ?????? ?????? ? ??????.
- ???????? ????????? ArchiveEntrySettings ?????? ? ?????????? ??? ????????? Storecompressionsettings ??????.
- ???????? ????????? Archive ?????? ? ????????? ??? ????????? ArchiveEntrySettings ??????, ?????????? ?? ???? ????.
- ???????? ???? ???????, ????????? ?? ???? 2, ????????? ????? archive.createEntry.
- ???????? ????????? ArchivesaveOptions ? ?????????? ??????????? Standardcharsets.us_ascii ? ?????????????? ?????? archivesaveoptions.setencoding.
- ???????????? ????? ??????, ????????? ????? archive.save ? ????????? ??? ????? ?????, ????????? ?? ???? 1, ? ????????? ArchivesaveOptions, ????????? ?? ???? ????.
1try (fileOutputStream ZipFile = new FileOutputStream (dataDir + "storeMultipleFileswithoutcompression_out.zip")) {
2 File fi1 = ????? ???? (datadir + "alice29.txt");
3 File fi2 = ????? ???? (datadir + "fields.c");
4 ?????????? (Archive Archive = ????? ????? (????? ???????????????? ?????? (????? storecompressionsettings ()))) {
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, ?????);
10 }
11} catch (ioException ????????????) {
12 System.out.println (Ex);
13}????????????? ???????????? ??? ?????? ??????
????: ????????????? ???????????? ??? ?????? ?????? ? ?????????????? java
- ???????? ???????? ????? ????? ? ???????? ?????? ?????? ????????? ZIP -?????.
- ???????? ?????? ????? ????? ??? ????? ?????? ? ??????? ?????? ??????, ??????? ????? ?????.
- ???????? ????????? Archive ??????.
- ???????? ????? ??????, ????????? ?? ???? 2, ????????? ????? Archive.createEntry.
- ???????? ????????? Paralleloptions ? ?????????? ParallelCompressionMode.Always ????????????? ParalleLoptions.setParalleLcompressInmemory ?????.
- ???????? ????????? ArchivesaveOptions ? ?????????? ???????????? ?????????? ? ??????????? ???? ??????????? ? ?????????????? ?????? ArchivesaveOptions.setParalloptions.
- ???????????? ????? ??????, ????????? ????? archive.save ? ????????? ??? ????? ?????, ????????? ?? ???? 1, ? ????????? ArchivesaveOptions, ????????? ?? ???? ????.
1try (fileOutputStream Zipfile = new FileOutputStream (datadir + "? ??????? PparalleLismTocompressFiles_out.zip")) {
2 try (fileInputStream Source1 = new FileInputStream (datadir + "alice29.txt")) {
3 try (fileInputStream Source2 = new FileInputStream (datadir + "asyoulik.txt")) {
4 Try (Archive Archive = ????? Archive (New ArchiveEntrySettings ())) {
5 Archive.createEntry ("alice29.txt", Source1);
6 Archive.createEntry ("asyoulik.txt", Source2);
7 Paralleloptions Paralleloptions = new Paralleloptions ();
8 paralleloptions.setparallelcpressinmemory (parallelcompressionmode.always);
9 ArchivesaveOptions Options = new ArchivesaveOptions ();
10 Options.SetParalleLoptions (Paralleloptions);
11 Options.SetencoDing (StandardCharsets.us_ascii);
12 Options.SetArchiveComment (�???? ??? ????? ?? ???????????????? ???????�);
13 archive.save (zipfile, ?????);
14 }
15 }
16 }
17} catch (ioException ex) {
18 System.out.println (Ex);
19}?????? LZMA ? ?????? ZIP
???????? ??????? Lempel - Ziv - ??????? ( lzma **) - ??? ????????, ???????????? ??? ?????????? ?????? ?????? ??? ??????.�LZMA ?????????? ???????? ?????? ???????, ?????? ????? ???????????? ????? ????? ?????. ?????? LZMA ? ?????? ZIP ????????? ZIP -??????????? ????????? ?????? ?????? LZMA. ? ????????? ??????? ???? ???????? ?????????? ?????? LZMA ? ?????????????? API Aspose.zip.
????: ?????? Lzma ? ?????? Zip ? ?????????????? java
- ???????? ???????? ????? ????? ? ???????? ?????? ?????? ????????? ZIP -?????.
- ???????? ????????? ArchiveEntrySettings ?????? ? ?????????? ??? ????????? lzmacompressionsettings ??????.
- ???????? ????????? Archive ?????? ? ????????? ??? ????????? ArchiveEntrySettings, ????????? ????.
- ???????? ????? ?????? ??? ?????? ? ??????? ????? ?????? ? ??????? ?????? archive.createEntry.
- ???????????? ????? ?????? ? ??????? ?????? archive.save.
1try (fileOutputStream ZipFile = new FileOutputStream (datadir + "lzmacompression_out.zip")) {
2 ?????????? (Archive Archive = New Archive (New ArchiveEntrySettings (New LzMacompressionSettings ()))) {
3 archive.createEntry ("sample.txt", datadir + "sample.txt");
4 Archive.save (Zipfile);
5 }
6} catch (ioException ????????????) {
7 System.out.println (Ex);
8}?????? BZIP2 ? ?????? ZIP
????????? ?????? BZIP2 ????????? ZIP -?????????? ????????? ?????? ?????? BZIP2.�? ????????? ??????? ???? ???????? ?????????? ?????? BZIP2 ? ?????????????? API Aspose.zip.
????: bzip2 ?????? ? ?????? zip ? ?????????????? java
- ???????? ???????? ????? ????? ? ???????? ?????? ?????? ????????? ZIP -?????.
- ???????? ????????? ArchiveEntrySettings ?????? ? ?????????? ??? ????????? bzip2compressionsettings ??????.
- ???????? ????????? Archive ?????? ? ????????? ??? ????????? ArchiveEntrySettings, ????????? ????.
- ???????? ????? ?????? ??? ?????? ? ??????? ????? ?????? ? ??????? ?????? archive.createEntry.
- ???????????? ????? ??????, ????????? ????? archive.save.
1try (fileOutputStream ZipFile = new FileOutputStream (datadir + "bzip2compression_out.zip")) {
2 ?????????? (Archive Archive = ????? ????? (????? ???????????????? ?????? (new bzip2compressionsettings ()))) {
3 archive.createEntry ("sample.txt", datadir + "sample.txt");
4 Archive.save (Zipfile);
5 }
6} catch (ioException ????????????) {
7 System.out.println (Ex);
8}????????????????? ??????
????? ?????????????? ? ????? ??????
1try (fileInputStream fs = new FileInputStream (datadir + "compresssinglefile_out.zip")) {
2 ?????????? (Archive Archive = New Archive (fs)) {
3 int [] inpityRead = new int [] {0};
4 archive.getEntries (). get (0) .setExtractionProgressed (New Event <prosingEventargs> () {
5 @Override
6 public void indoke (??????????? ????????, ProgressEventargs ProgressEventargs) {
7 int procet = (int) ((100 * ProgressEventargs.getProudeedBytes ())
8 / ((ArchiveEntry) ???????????) .getUncompressedSize ());
9 if (???????> ??????? ?????? [0])
10 {
11 System.out.println (??????? + "% ????????????????");
12 ??????? ?????? [0] = ???????;
13 }
14 }
15 });
16 archive.getEntries (). get (0) .extract (datadir + "alice_extracted_out.txt");
17 }
18} catch (ioException ex) {
19 System.out.println (Ex);
20}????? ?????????? ? ??????????? ???????
1try (fileInputStream fs = new FileInputStream (datadir + "compressMultiplefiles_out.zip")) {
2 StringBuilder SB = new StringBuilder ("??????:");
3 int [] inpityRead = new int [] {0};
4 Archiveloadoptions Options = new ArchiveLodoptions ();
5 Options.SetEntryListed (New Event <pretniEventargs> () {
6 @Override
7 public void indoke (??????????? ????????, enteventargs enteventargs) {
8 SB.Append (enteVentargs.getEntry (). getName ()). Append (",");
9 }
10 });
11 Options.setEntryExtractionProgressed (New Event <progressEventargs> () {
12 @Override
13 public void indoke (??????????? ????????, ProgressEventargs ProgressEventargs) {
14 int procet = (int) ((100 * ProgressEventargs.getProudeedBytes ())
15 / ((ArchiveEntry) ???????????) .getUncompressedSize ());
16 if (???????> ??????? ?????? [0])
17 {
18 System.out.println (??????? + "% ??????");
19 ??????? ?????? [0] = ???????;
20 }
21 }
22 });
23 ?????????? (Archive Archive = New Archive (fs, Options)) {
24 System.out.println (sb.substring (0, sb.length () - 2));
25 try (fileOutputStream Extracted = new FileOutputStream (dataDir + "alice_extracted_out.txt")) {
26 try (inputstream decompressed = archive.getEntries (). get (0) .open ()) {
27 ???? [] ????? = ????? ???? [8192];
28 int bytesread;
29 while (0 <(bytesread = decompressed.read (buffer, 0, buffer.length))) {
30 ????????.
31 }
32 // ?????? ?? ???????????????????? ?????? ? ?????????? ?????.
33 }
34 }
35 ??????? ?????? [0] = 0;
36 archive.getEntries (). get (1) .extract (datadir + "asyoulik_extracted_out.txt");
37 }
38} catch (ioException ex) {
39 System.out.println (Ex);
40}?????????? ????????? ?????? ??? ??????
1try (fileInputStream ZipFile = new FileInputStream (datadir + "StoreMultipleFileswithoutCompression_out.zip")) {
2 ?????????? (????? ????? = ????? ????? (Zipfile)) {
3 try (fileOutputStream Extracted = new FileOutPutStream (datAdir + "alice_extracted_store_out.txt")) {
4 try (inputstream nase = archive.getEntries (). get (0) .open ()) {
5 ???? [] ????? = ????? ???? [8192];
6 int bytesread;
7 while (0 <(bytesread = hare.read (buffer, 0, buffer.length))) {
8 ????????.
9 }
10 // ?????? ?? ???????????? ?????? ??? ?????????? ?????.
11 }
12 }
13 try (fileOutputStream Extracted = new FileOutputStream (datAdir + "asyoulik_extracted_store_out.txt")) {
14 try (inputstream nase = archive.getEntries (). get (1) .open ()) {
15 ???? [] ????? = ????? ???? [8192];
16 int bytesread;
17 while (0 <(bytesread = hare.read (buffer, 0, buffer.length))) {
18 ????????.
19 }
20 // ?????? ?? ???????????? ?????? ??? ?????????? ?????.
21 }
22 }
23 }
24} catch (ioException ex) {
25 System.out.println (Ex);
26}