ZIP and GZIP

  • Themenstarter Gelöschtes Mitglied 76266
  • Beginndatum
G

Gelöschtes Mitglied 76266

Gast
Hi
Java offers developers many possibilities to invent or to develop fancy apps. ZIP is known as a data compression technology. GNU optimized the compression algorithm and named it GZIP (Gnu ZIP). But GZIP works mainly with a data stream (e.g. used by HTTP for the WEB). To compress files or directories with GZIP you need to develop your own app. And I did: JZIP for Java ZIP.

JZIP has only 3 sources:
  • JZIP.java: the GUI frame
  • JZIPIOStream.java: the IO with ZIP or GZIP -dependent on the specified format.
  • joe.css: the CSS file used by JZIP
The codes are JavaFX (compiled on JDK 9.0.4). To compress files and/or directories GZIP uses the following data format:
Java:
 0            1 2           5 6                                   n
+--------------+-------------+-----//-------+----------//----------+
! path length  ! data length ! path-name    ! data                 !
+--------------+-------------+----//--------+---------//-----------+
path length gives the path name length (in bytes). Max 256 bytes
data length gives the number of bytes of the file content
Example:
/JoeApp/jzip/JZIP.java: path length = 22 bytes (absolute) or relative without directory: 9 bytes

Two ArrayLists are used to list the path/file names and contents (in bytes)
Some screenshots for your reviews:
 

Anhänge

  • jzip1.jpg
    jzip1.jpg
    55,4 KB · Aufrufe: 1
  • jzip2.jpg
    jzip2.jpg
    38 KB · Aufrufe: 1
  • jzip3.jpg
    jzip3.jpg
    30,1 KB · Aufrufe: 3
  • jzip4.jpg
    jzip4.jpg
    28,5 KB · Aufrufe: 3
  • JavaForum.zip
    11,6 KB · Aufrufe: 4

mihe7

Top Contributor
GZIP and ZIP are archive formats, where GZIP can only hold a single file. Both of them (can) make use the 'deflate' algorithm for compression. To use GZIP with multiple files, one can use an archive format which supports multiple files (like tar) and compress the archive using GZIP.

That is, 'deflate' is used for all files in this archive and that is where ZIP comes in: a ZIP-file is an archive containing one or more files, each of which can be compressed by a different algorithm. As already mentioned, 'deflate' can also be used there.

What is the advantage of your tool?
 

Neue Themen


Oben