?????? ? ???????? GZIP

?????

Aspose.zip ??? Java API ????????? ???????? ? ????????? ? ??????????? ???????? GZIP ? ????? ??????????? ??? ????????????? ????? -???? ?????? ????????? ??????????.�Aspose.zip API ????????????? gziparchive ????? ??? ?????? ? ???????? Gzip. ???? ????? ????????????? ????????? ?????? ??? ?????????? ???????? ? ???????.

???????? ?????? GZIP ??????? ?? ????????? ????????, ??????? ???????????? ????? ?????????? ??????????? LZ77 ? Huffman.

?????? ?????

? ????????? ??????? ???? ????????, ??? ????? ???? ? ??????? gziparchive ??????????.

1?????????? (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 Extracted = new FileOutputStream (datadir + "data.bin")) {
 3        InputStream unpacked = archive.open ();
 4        ???? [] b = ????? ???? [8192];
 5        int bytesread;
 6        while (0 <(bytesread = unpacked.read (b, 0, b.length))) {
 7            ????????.
 8        }
 9    }
10} catch (ioException ex) {
11    System.out.println (Ex);
12}

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

? ????????? ??????? ???? ????????, ??? ??????? ????? ?? ?????? ? ??????? ??? ? BytearrayOutputStream.

 1BytearRayOutputStream outpertStream = 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, BytesRead);
 8    }
 9    System.out.println (archive.getName ());
10} catch (ioException ex) {
11    System.out.println (Ex);
12}

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

? ????????? ??????? ???? ????????, ??? ??????? ? ????????? ? outputstream.

1BytearRayOutputStream outpertStream = new BytearRayOutputStream ();
2?????????? (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.