GZIP ????? ?????

??

Java API ? zip? ???? ?? ? 3 ? ???????? ?? ?????? GZIP ????? ???? ???? ??? ?? ? ? ????.�aspose.zip api? gziparchive ???? ???? GZIP ????? ?? ?????. ? ???? ?????? ??? ???? ??? ??? ?????.

GZIP ?? ????? LZ77? Huffman ??? ?? ? Deflate ????? ???????.

?? ??

?? ?? ??? gziparchive ????? ???? ??? ???? ??? ?????.

1try (gziparchive archive = new gziparchive ()) {
2    archive.setsource (datadir + "data.bin");
3    archive.save (datadir + "archive.gz");
4}

GZIP ???? ??

?? ?? ??? GZIP ????? ?? ??? ?????.

 1try (gziparchive archive = new gziparchive (datadir + "archive.gz")) {
 2    try (fileoutputStream ?? = ? FileOutputStream (datAdir + "data.bin")) {
 3        inputStream ???? ?? = archive.open ();
 4        ??? [] B = ??? ??? [8192];
 5        int bytesread;
 6        while (0 <(bytesRead = ???? ??. ?? (b, 0, b.length))) {
 7            extracted.write (b, 0, ??? ???);
 8        }
 9    }
10} catch (ioException ex) {
11    System.out.println (?);
12}

?? ???? ??

?? ?? ??? ????? ????? ?? BytearRayoutputStream?? ???? ??? ?????.

 1bytearrayoutputStream outputStream = new BytearRayoutputStream ();
 2try (gziparchive archive = new gziparchive (new FileInputStream (datadir + "sample.gz"))) {
 3    ??? [] B = ??? ??? [8192];
 4    int bytesread;
 5    inputstream archivestream = archive.open ();
 6    while (0 <(bytesread = archivestream.read (b, 0, b.length))) {
 7        outputStream.write (b, 0, ??? ???);
 8    }
 9    System.out.println (Archive.getName ());
10} catch (ioException ex) {
11    System.out.println (?);
12}

?? ???? ??

?? ?? ??? OutputStream? ?? ???? ??? ?????.

1bytearrayoutputStream outputStream = new BytearRayoutputStream ();
2try (gziparchive archive = new gziparchive ()) {
3    archive.setsource (? ?? (datadir + "data.bin");
4    Archive.save (OutputStream);
5}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.