?? ????????? ?? ??????????? ????? ?? java

?????

?? ?????? ??????? ??? ????????? ???????? ??????? ?????, ?????????????? ???????????? ??????, ?? ?????????????? API Java ?? ?????? ????. ?? ??????????, ?? ???????? ??? ???????? ???? ??? ?????? ??????, ? ????? ?? ????????? zip -??????. ?? ????? ??????????, ?? ????? ?????????????? ??? ??????????? ?????.

????? zip ??? ????????? ? java ?? ?????????????? ??? ??????????? ????? ? java

Aspose.zip API ???????? ???????? ?? ?????????????? ?????, ?? ?????????? ??? ??????? ????????? ??????. ?? ?????? ??????? ?????? ? ?????????, ? ????? ?????????? ??????????? ??????.

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

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

?????: ????????? ?????? ????? ? Java

  1. ???????? ????? ?????? ????? ? ????????? ?????? ?????? ????????? Zip -?????.
  2. ???????? ????? ???????? ????? ????? ?????, ???? ???????? ????????.
  3. ???????? ????????? ?????? ????? ?? ????????? ???? ????????? ArchiveEntrySettings ?????.
  4. ?????? ???? ?????, ????????? ?? ????? 2, ?????????????? ????? Archive.CreateEntry.
  5. ????????????? ???? ????? ?? ????????? ?????? Archive.save ? ????????? ???? ????? ?????, ?????????? ?? ????? 1.
 1????????? (fileOutputStream Zipfile = ????? FileOutputStream (DataDir + "CompresssingleFile_out.zip") {
 2    // ????, ???? ???????? ?????? ?? ??????
 3    ????????? (fileInputStream ourse1 = ????? FileInputStream (DataDir + "alice29.txt")) {
 4        ????????? (????? ????? = ????? ????? (????? ArchiveEntrySettings ())) {
 5            Archive.createEntry ("alice29.txt", ???????1);
 6            Archive.save (Zipfile);
 7        }
 8    }
 9} ???? (IOException ex) {
10    System.out.println (ex);
11}

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

?????: ????????? ????????? ?????? ? Java

  1. ???????? ????? ????? ? ????????? ?????? ?????? ????????? Zip -?????.
  2. ???????? ????? ????? ??????? ????? ?????, ???? ???????? ????????.
  3. ???????? ????? ????? ??????? ????? ?????, ???? ???????? ????????.
  4. ???????? ????????? ?????? ?????.
  5. ?????? ????? ?????, ???????? ?? ????? 2 ?? ????? 3, ?????????????? ????? Archive.CreateEntry.
  6. ???????? ????????? ArchivesaveOptions ?????.
  7. ????????????? ????? ????? ?? ????????? ?????? Archive.save ?? ????????? ???? ????? ?????, ?????????? ?? ????? 1, ?? ?????????? ArchivesaveOptions, ???????? ?? ????????????? ?????.
 1????????? (fileOutputStream Zipfile = ????? FileOutputStream (DataDir + "CompresssingleFile_out.zip") {
 2    ????????? (fileInputStream ourse1 = ????? FileInputStream (DataDir + "alice29.txt")) {
 3        ????????? (fileInputStream ourse2 = ????? FileInputStream (DataDir + "asyoulik.txt")) {
 4            ????????? (????? ????? = ????? ????? (????? ArchiveEntrySettings ())) {
 5                Archive.createEntry ("alice29.txt", ???????1);
 6                archive.createEntry ("asyoulik.txt", ???????2);
 7                ArchivesaveOptions Options = ???? ?????????????? ();
 8                ?????.setEncoding (StandardCharsets.us_ascii);
 9                ????????.setarchiveComment ("? ??? ????? ? ?????????? ???????");
10                Archive.save (Zipfile, ????????);
11            }
12        }
13    }
14} ???? (IOException ex) {
15    System.out.println (ex);
16}

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

?????: ???????? ????? ?? ??????????? ??? ???? ? Java

  1. ????????? ????? ?????? ????? ? ????????? ?????? ?????? ????????? Zip -?????.
  2. ???????? ???? ??’??? ?????? ??????? ????? ?????, ???? ???????? ????????.
  3. ???????? ???? ??’??? ?????? ??????? ????? ?????, ???? ???????? ?????????.
  4. ???????? ????????? ?????? ?????.
  5. ?????? ????? ?????, ???????? ?? ????? 2 ?? ????? 3, ?????????????? ????? Archive.CreateEntry.
  6. ???????? ????????? ArchivesaveOptions ?????.
  7. ????????????? ????? ????? ?? ????????? ?????? Archive.save ?? ????????? ???? ????? ?????, ?????????? ?? ????? 1, ?? ?????????? ArchivesaveOptions, ???????? ?? ????????????? ?????.
 1????????? (fileOutputStream Zipfile = ????? FileOutputStream (DataDir + "CompressFilesByFileInfo_out.zip")) {
 2    ???? fi1 = ????? ???? (DataDir + "alice29.txt");
 3    ???? fi2 = ????? ???? (DataDir + "fields.c");
 4    ????????? (????? ????? = ????? ????? ()) {
 5        Archive.CreateEntry ("alice29.txt", fi1);
 6        Archive.createEntry ("fields.c", fi2);
 7        ArchivesaveOptions Options = ???? ?????????????? ();
 8        ?????.setEncoding (StandardCharsets.us_ascii);
 9        Archive.save (Zipfile, ????????);
10    }
11} ???? (IOException ???????????) {
12    System.out.println (ex);
13}

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

?????: ?????????? ?????? ?? ??????? ??? ????????? ?? ????????? Java

  1. ????????? ????? ?????? ????? ? ????????? ?????? ?????? ????????? Zip -?????.
  2. ???????? ??’???? ????? ??? ?????????? ?????? ????? ? ??????.
  3. ???????? ????????? ArchiveEntrySettings ????? ?? ????????? ???? ????????? storecompressionsettings ?????.
  4. ???????? ????????? ?????? ????? ?? ????????? ???? ????????? ArchiveEntrySettings ????, ????????? ?? ????????????? ?????.
  5. ??????? ???? ??’????, ???????? ?? ????? 2, ?????????????? ????? archive.createEntry.
  6. ???????? ????????? ArchivesaveOptions ?? ?????????? ????????? ?? StandardCharsets.us_ascii ?? ????????? ?????? archivesaveOptions.setEncoding.
  7. ????????????? ????? ????? ?? ????????? ?????? Archive.save ?? ????????? ???? ????? ??????, ?????????? ?? ????? 1, ?? ?????????? ArchivesaveOptions, ???????? ?? ????????????? ?????.
 1????????? (fileOutputStream Zipfile = ????? FileOutputStream (DataDir + "StoreMultipleFilesWithOutCompression_out.zip") {
 2    ???? fi1 = ????? ???? (DataDir + "alice29.txt");
 3    ???? fi2 = ????? ???? (DataDir + "fields.c");
 4    ????????? (????? ????? = ????? ????? (????? ArchiveEntrySettings (???? Storecompressionsettings ()))) {
 5        Archive.CreateEntry ("alice29.txt", fi1);
 6        Archive.createEntry ("fields.c", fi2);
 7        ArchivesaveOptions Options = ???? ?????????????? ();
 8        ?????.setEncoding (StandardCharsets.us_ascii);
 9        Archive.save (Zipfile, ????????);
10    }
11} ???? (IOException ???????????) {
12    System.out.println (ex);
13}

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

?????: ???????????? ??????????? ??? ????????? ?????? ?? ????????? Java

  1. ????????? ????? ?????? ????? ? ????????? ?????? ?????? ????????? Zip -?????.
  2. ????????? ?????? ???????? ?????? ??? ????????? ?????? ?? ??????? ????? ?????.
  3. ???????? ????????? ?????? ?????.
  4. ?????? ????? ?????, ???????? ?? ????? 2, ?????????????? ????? Archive.CreateEntry.
  5. ???????? ????????? ???????????? ?? ?????????? parallelcompressionMode.Always ?? ????????? paralleloptions.setParalleLcompressInMemory.
  6. ???????? ????????? ArchivesaveOptions ?? ?????????? ?????????? ????????? ? ??????????????, ?????????????? ????? archivesaveOptions.setParallelOloptions.
  7. ????????????? ????? ?????, ?????????????? ????? Archive.save ? ????????? ???? ????? ?????, ?????????? ?? ????? 1, ?? ?????????? ArchivesaveOptions, ???????? ?? ????????????? ?????.
 1????????? (fileOutputStream Zipfile = ????? FileOutputStream (DataDir + "????????????ParallelismTocompressFiles_out.zip")) {
 2    ????????? (fileInputStream ourse1 = ????? FileInputStream (DataDir + "alice29.txt")) {
 3        ????????? (fileInputStream ourse2 = ????? FileInputStream (DataDir + "asyoulik.txt")) {
 4            ????????? (????? ????? = ????? ????? (????? ArchiveEntrySettings ())) {
 5                Archive.createEntry ("alice29.txt", ???????1);
 6                archive.createEntry ("asyoulik.txt", ???????2);
 7                ???????????? ???????????? = ???? ???????????? ();
 8                paralleloptions.setparallelcompressinmemory (parallelcompressionmode.always);
 9                ArchivesaveOptions Options = ???? ?????????????? ();
10                ?????????.setParallelOloptions (????????????);
11                ?????.setEncoding (StandardCharsets.us_ascii);
12                ????????.setarchiveComment ("? ??? ????? ? ?????????? ???????");
13                Archive.save (Zipfile, ????????);
14            }
15        }
16    }
17} ???? (IOException ex) {
18    System.out.println (ex);
19}

????????? LZMA ? Zip Archive

???????? ??????? ??????? -??? -??????? (lzma) - ?? ????????, ???? ???????????????? ??? ????????? ????????? ????? ??? ?????.�LZMA ???????????? ???????? ????????? ????????, ??????? ????? - ?? ????? ?????????. ????????? LZMA ????????? ?????? ZIP ???????? ??????????? zip ??????? ???????? ?????? LZMA. ????????? ??????? ???? ??????? ?????????? ????????? LZMA ?? ????????? ASPOSE.ZIP API.

?????: lzma ????????? ? ?????? zip ? ????????????? Java

  1. ????????? ????? ?????? ????? ? ????????? ?????? ?????? ????????? Zip -?????.
  2. ???????? ????????? ArchiveEntrySettings ????? ?? ????????? ???? ????????? Lzmacompressionsettings ?????.
  3. ???????? ????????? ?????? ????? ? ????????? ???? ????????? ArchiveEntrySettings, ?????????? ????.
  4. ??????? ????? ?????, ??? ????? ???????? ?? ????????? ?????? ?????? archive.createEntry ??????.
  5. ????????????? ????? ????? ?? ????????? ?????? Archive.save.
1????????? (fileOutputStream Zipfile = ????? FileOutputStream (DataDir + "Lzmacompression_out.zip") {
2    ????????? (Archive Archive = ????? ????? (????? ArchiveEntrySettings (???? Lzmacompressionsettings ()))) {
3        Archive.createEntry ("sample.txt", datadir + "sample.txt");
4        Archive.save (Zipfile);
5    }
6} ???? (IOException ???????????) {
7    System.out.println (ex);
8}

????????? BZIP2 ? Zip Archive

???????????? ????????? BZIP2 ?????????? ????????? zip ??????? ???????? ?????? BZIP2.�????????? ??????? ???? ??????? ?????????? ????????? BZIP2 ?? ????????? Aspose.zip API.

?????: bzip2 ????????? ? Zip Archive, ?????????????? Java

  1. ????????? ????? ?????? ????? ? ????????? ?????? ?????? ????????? Zip -?????.
  2. ???????? ????????? ArchiveEntrySettings ????? ?? ????????? ???? ????????? Bzip2Compressionsettings ?????.
  3. ???????? ????????? ?????? ????? ? ????????? ???? ????????? ArchiveEntrySettings, ?????????? ????.
  4. ?????? ????? ?????, ??? ????? ???????? ?? ????????? ?????? ?????? archive.createEntry ??????.
  5. ????????????? ????? ????? ?? ????????? ?????? Archive.save.
1????????? (fileOutputStream Zipfile = ????? FileOutputStream (DataDir + "Bzip2compression_out.zip") {
2    ????????? (Archive Archive = ????? ????? (????? ArchiveEntrySettings (???? bzip2compressionsettings ())) {
3        Archive.createEntry ("sample.txt", datadir + "sample.txt");
4        Archive.save (Zipfile);
5    }
6} ???? (IOException ???????????) {
7    System.out.println (ex);
8}

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

???????? ?????, ?? ??? ???? ????

 1????????? (fileInputStream fs = ????? FileInputStream (DataDir + "Compresssinglefile_out.zip")) {
 2    ????????? (????? ????? = ????? ????? (FS)) {
 3        int [] ???????? = ????? int [] {0};
 4        archive.getentries (). Get (0) .setextractionProgress (???? ????? <PlasseventArgs> () {
 5            @Override
 6            public void App (?????????? ??'?????, ???????????????? Progresseventargs) {
 7                int ????????? = (int) ((100 * progresseventargs.getproceceedbytes ())
 8                        / ((ArchiveEntry) ??????????) .getUnCompressedSize ());
 9                ???? (????????> ???????? [0])
10                {
11                    System.out.println (???????? + "% ???????????");
12                    ???????? [0] = ????????;
13                }
14            }
15        });
16        archive.getentries (). get (0) .extract (DataDir + "alice_extracted_out.txt");
17    }
18} ???? (IOException ex) {
19    System.out.println (ex);
20}

???????? ?????, ?? ??? ?????? ??????

 1????????? (fileInputStream fs = ????? FileInputStream (DataDir + "CompressMultipleFiles_out.zip") {
 2    StringBuilder SB = ????? StringBuilder ("??????:");
 3    int [] ???????? = ????? int [] {0};
 4    ????????? ArchiveLoadoptions = ???? ??????????????? ();
 5    Options.setEntryListed (???? ????? <entryeventargs> () {
 6        @Override
 7        public void App (?????????? ??'?????, entryeventargs entryeventargs) {
 8            sb.append (entryeventargs.getentry (). getName ()). ?????? (",");
 9        }
10    });
11    Options.setEntryExtractionProgress (???? ????? <ProgressEventArgs> () {
12        @Override
13        public void App (?????????? ??'?????, ???????????????? Progresseventargs) {
14            int ????????? = (int) ((100 * progresseventargs.getproceceedbytes ())
15                    / ((ArchiveEntry) ??????????) .getUnCompressedSize ());
16            ???? (????????> ???????? [0])
17            {
18                System.out.println (???????? + "% ??????????");
19                ???????? [0] = ????????;
20            }
21        }
22    });
23    ????????? (????? ????? = ????? ????? (FS, ?????????)) {
24        System.out.println (SB.Substring (0, SB.Length () - 2);
25        ????????? (fileOutputStream extreated = ????? FileOutputStream (DataDir + "alice_extracted_out.txt") {
26            ????????? (inputStream decompressed = archive.getentries (). get (0) .open ()) {
27                ???? [] ????? = ????? ???? [8192];
28                int bytesread;
29                while (0 <(bytesread = decompressed.read (?????, 0, buffer.length)) {
30                    ??????????.write (?????, 0, bytesread);
31                }
32                // ?????????? ? ???????????????? ?????? ?? ????????? ?????.
33            }
34        }
35        ???????? [0] = 0;
36        archive.getentries (). get (1) .extract (dataDir + "asyoulik_extracted_out.txt");
37    }
38} ???? (IOException ex) {
39    System.out.println (ex);
40}

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

 1????????? (fileInputStream Zipfile = ????? FileInputStream (DataDir + "storeMultipleFilesWithoutCompression_out.zip") {
 2    ????????? (????? ????? = ????? ????? (Zipfile)) {
 3        ????????? (FileOutputStream extreated = ????? FileOutputStream (DataDir + "alice_extracted_store_out.txt")) {
 4            ????????? (inputstream inder = archive.getentries (). get (0) .open ()) {
 5                ???? [] ????? = ????? ???? [8192];
 6                int bytesread;
 7                while (0 <(bytesread = indered.read (?????, 0, buffer.length)) {
 8                    ??????????.write (?????, 0, bytesread);
 9                }
10                // ?????????? ??? ??????????? ?????? ?? ????????? ?????.
11            }
12        }
13        ????????? (FileOutputStream extalted = ????? FileOutputStream (DataDir + "asyoulik_extracted_store_out.txt")) {
14            ????????? (inputstream inder = archive.getentries (). get (1) .open ()) {
15                ???? [] ????? = ????? ???? [8192];
16                int bytesread;
17                while (0 <(bytesread = indered.read (?????, 0, buffer.length)) {
18                    ??????????.write (?????, 0, bytesread);
19                }
20                // ?????????? ??? ??????????? ?????? ?? ????????? ?????.
21            }
22        }
23    }
24} ???? (IOException ex) {
25    System.out.println (ex);
26}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.