

{"id":78834,"date":"2020-07-01T15:50:16","date_gmt":"2020-07-01T10:20:16","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=78834"},"modified":"2020-07-01T17:49:29","modified_gmt":"2020-07-01T12:19:29","slug":"java-project-compression-decompression","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/","title":{"rendered":"Java Project &#8211; Compression and Decompression [Source Code Included]"},"content":{"rendered":"<p><strong>Java Project &#8211; Compression and Decompression<\/strong><\/p>\n<p>This is a Java project for beginners, implement your learnings on real-time projects.\u00a0Just theoretical knowledge is not sufficient, you have to work on real-time projects. In this article, DataFlair is providing you a live project with complete implementation along with the source code, so that you can easily master Java<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78854\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression.jpg\" alt=\"java project compression decompression\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h3>Project Objective<\/h3>\n<p>We sometimes face problems related to memory issues while saving or transferring any document or a file. Hence, there is a need to compress it so that it is reduced in size and can be transferred and processed easily. Data Compression and Decompression provide users to store data in less space and also easier for the user to transfer over the network. The Compression reduces the file of the size so that we can share it easily over any network even at a slow speed. This project aims at compressing and decompressing different types of files stored in our computer system at a particular destination location. There are four different algorithms that can be chosen to compress or decompress the files.<\/p>\n<h3>Data Compression and Decompression<\/h3>\n<p>Compression is the process of encoding information using fewer bits than the original representation of the data. Compression of data is useful as it reduces the resources required to store the data and transmit it over the network. When we talk about data transmission, it is called source encoding. Before transmitting the data, encoding is done for security purposes. The reverse process of compression is called decompression which is used to get the original data from the compressed data.<\/p>\n<h3>Need to develop this system<\/h3>\n<p>In the present system, there are so many problems while transferring or sharing a file of large size. These files cannot be sent over a network if they are above certain size limits. Even if the size of the file is small but if the internet connection speed is slow, then too it is difficult to send them. These limitations create a lot of problems when we need to share an urgent file and we just can&#8217;t due to the size limit of the file. Therefore, there is a need to build a system that can compress and decompress the files easily so they can be shared efficiently without any constraint.<\/p>\n<p><strong>Some important reasons for developing this project are:<\/strong><\/p>\n<ul>\n<li>The intention of file compression is to significantly reduce the space to store a file and transmit it<\/li>\n<li>File compression also increases data transfer speed. It is obvious that the longer file would take more time to be transferred and there is a maximum possibility of interruption between the file transfer process<\/li>\n<li>There is also a chance of the file being corrupted and the user gets a file which is of no use<\/li>\n<li>Compression also reduces the disk space required on the internet servers along with the time taken by the Internet servers to find the file stored on the hard drive<\/li>\n<li>File Compression also provides file security by hiding information. This is useful when we do not want information to be available to the public. This can be done by compressing a file that can\u2019t be decompressed by a commonly used computer software.<\/li>\n<\/ul>\n<h3>Data Compression and Decompression project in Java<\/h3>\n<p>The project &#8220;Data Compression and Decompression&#8221; System is totally built on Java technology and provides an interface to the users so that they can easily store and transfer large files. This java project also provides encoding techniques in compression so as to ensure the security of the data. Using this project, the users can compress the data according to the requirement at any point and for any number of times.<\/p>\n<p>The layout of the project is built using the swing and AWT packages of Java using their predefined classes, interfaces, and methods. The io(Input Output) and util packages of Java provide the predefined classes to compress and decompress the files directly by passing the filename and location.<\/p>\n<h3>Technology and IDE used to run the project:<\/h3>\n<ul>\n<li>Java 1.8 or above<\/li>\n<li>Eclipse or Netbeans or IntelliJ<\/li>\n<\/ul>\n<h3>Algorithms used to compress and decompress<\/h3>\n<p>We have used 4 algorithms for compression and decompression in this project. They are:<\/p>\n<ul>\n<li>LZW<\/li>\n<li>GZIP<\/li>\n<li>HUFFMAN<\/li>\n<li>RUNLENGTH<\/li>\n<\/ul>\n<h4>1. LZW Algorithm:<\/h4>\n<p>The <a href=\"https:\/\/users.cs.cf.ac.uk\/Dave.Marshall\/Multimedia\/node214.html\">LZW algorithm<\/a> stands for Lempel-Ziv-Welch. These three were the inventors of these algorithms. It is a compression algorithm that compresses a file into a smaller one using a table-based lookup. This algorithm is mainly used to compress GIF files and optionally to compress and PDF and TIFF files. The files compressed using this algorithm are saved with .lzw extension.<\/p>\n<h4>2. GZIP Algorithm:<\/h4>\n<p>The GZIP stands for the GNU Zip algorithm and is used to compress the files into a gzip file format. This file format must not be confused with the ZIP archive file format as the gzip works on a single file. The GZIP is based on the Deflate algorithm.<\/p>\n<h4>3. HUFFMAN Algorithm<\/h4>\n<p>Huffman coding algorithm is a data compression algorithm that works by creating a binary tree of nodes. All nodes contain the character itself and priority queue is applied to build a binary tree.<\/p>\n<h4>4. RUNLENGTH Algorithm<\/h4>\n<p>Run length compression or Run Length Encoding(RLE) works by reducing the physical size of a repeating string of characters. This repeating string is called \u2018run\u2019 and the size is called \u2018length\u2019. This type of compression is mainly used for file formats such as TIFF, BMP, and PCX.<\/p>\n<h3>Download the project source code:<\/h3>\n<p>Please download the source code of project: <strong><a href=\"https:\/\/data-flair.training\/blogs\/download-compression-decompression-project-source-code\/\">Compression &amp; decompression project code<\/a><\/strong><\/p>\n<p>Now, we have a .rar file. Please save this folder into a project folder. Now right click on this file and select \u201cExtract here\u201d option:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-extract.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78837\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-extract.png\" alt=\"project extract\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-extract.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-extract-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-extract-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-extract-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-extract-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-extract-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-extract-520x279.png 520w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h3>Import and execute the project<\/h3>\n<p>Now, we need to import this project in our Eclipse IDE. Let&#8217;s start:<\/p>\n<p>1. Open Eclipse<\/p>\n<p>2. Click the file menu button and choose open project from file system option:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-eclipse.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78838\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-eclipse.png\" alt=\"import project eclipse\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-eclipse.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-eclipse-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-eclipse-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-eclipse-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-eclipse-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-eclipse-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-eclipse-520x279.png 520w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>3. Click the Directory Button:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78839\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project.png\" alt=\"import project\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-520x279.png 520w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>4. Now, select the folder that we extracted previously.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78840\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-2.png\" alt=\"import project select folder\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-2.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-2-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-2-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-2-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-2-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-2-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-2-520x279.png 520w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>5. The project is now imported in the eclipse:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-done.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78841\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-done.png\" alt=\"import project done\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-done.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-done-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-done-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-done-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-done-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-done-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/import-project-done-520x279.png 520w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h3>Classes and Interfaces used in the project<\/h3>\n<p>We have used Swing and AWT to create the layout of the project.<\/p>\n<p>In <strong>CGZipCompressor<\/strong> folder, there are two java classes:<\/p>\n<h4>CGZipEncoder.java<\/h4>\n<p>In this class, we have imported the java.io package for using the file operations and util.zip.GZIPOutputStream class . This class implements a stream filter for writing compressed data in the GZIP file format. We also define a loadFile() method overloaded with different number of parameters. The boolean encodeFile() method returns true on the successful encoding of the file.<\/p>\n<h4>CGZipDecoder.java<\/h4>\n<p>In this class, we have imported the java.io package for using the file operations and util.zip.GZIPInputStream class . This class implements a stream filter for reading compressed data in the GZIP file format. We also define a loadFile() method overloaded with different number of parameters. The boolean decodeFile() method returns true on the successful decoding of the file.<\/p>\n<p>In CHuffmanCompressor folder, there are four java classes and an interface<\/p>\n<h4>CHuffmanEncoder.java<\/h4>\n<p>The class CHuffmanEncoder implements the HuffmanSignature interface which is defined in the HuffmanSignature.java in another file. It has three constructors that call the loadFile() method with different arguments. The encodeFie() method returns true if the file is encoded successfully. There are methods to build and get the Huffman codes.<\/p>\n<h4>CHuffmanDecoder.java<\/h4>\n<p>This class also implements the HuffmanSignature interface. It is used to decode the Hiffman codes to get the original file. There are three constructors in which we have called the loadFile() method with different arguments. The decodeFile() method is of boolean type and returns true on successful decoding of the file. There is an int findCodeword() method that finds the codeword for the Huffman code.<\/p>\n<h4>HuffmanNode.java<\/h4>\n<p>This class stores all the nodes of the Huffman tree.<\/p>\n<h4>CPriorityQueue.java<\/h4>\n<p>The CPriorityQueue class is used to find the Huffman codes for every character of the file. There are several functions like enqueue(), dequeue(), isFull(), totalNodes() in this class.<br \/>\nInterface:<\/p>\n<h4>HuffmanSignature.java<\/h4>\n<p>This is an interface that declares final variables with a value.<\/p>\n<p>In CLZWCompressor, there are two classes and one interface<\/p>\n<h4>CLZWEncoder.java<\/h4>\n<p>This class implements the LZWInterface and creates instances using different constructors. There is a boolean method called encodeFile() that returns true on successful encoding of the file.<\/p>\n<h4>CLZWDecoder.java<\/h4>\n<p>This class implements the LZWInterface and creates new instances by defining constructors with different parameters. We also use hashtable as this algorithm is table-based and stores values in a table. There is a boolean method called decodeFile() that returns true on the successful decoding of the file.<\/p>\n<h4>LZWInterface.java<\/h4>\n<p>This interface defines the final variables.<\/p>\n<p>In <strong>CRLECompressor<\/strong>, there are two classes and one interface<\/p>\n<h4>CRLEEncoder<\/h4>\n<p>This class implements the RLEInterface. The method encodeFile() creates two instances, one of input files and another of output file, and then copies the single byte from input source file to output source file. In the output, it adds the extension provided by the user at the runtime(I.e., rle extension).<\/p>\n<h4>CRLEDecoder<\/h4>\n<p>This class also implements RLEInterface. In this also, there are two file sources, one is of RLE signature and destination file. Then we read file character-wise until we get an escape character. Finally, we get the original file at a particular location with the file size.<\/p>\n<h4>RLEInterface<\/h4>\n<p>In this interface, we have defined some final variables with some initial values.<\/p>\n<p>In the <strong>FileBitIO folder<\/strong>, there are 3 classes and one Form file<\/p>\n<h4>CFileBitReader.java<\/h4>\n<p>This class imports the java.io package to use the classes and methods related to input File. This class mainly deals with reading from the input file. There is a loadFile() method that is used to load the file. There is a getBit() method that converts the file into the form of bits. The getByte() method returns the file in the form of bytes or 8-bit sequence. There is eof method that checks whether the file has reached to end or not. The closeFile() method closes the file object. We have used these methods in other classes directly to perform the file operations.<\/p>\n<h4>CFileBitWriter.java<\/h4>\n<p>This class also uses the java.io package and deals with writing to the file. There are methods like putBit(), putBits(), and putString() to write into the file in different formats-either bitwise or bytewise. It also has closeFile() method to close the file after writing.<\/p>\n<h4>GfhWorkingDlg.form<\/h4>\n<p>This is an xml file that defines all the components and dimensions of the components.<\/p>\n<p>In wingph folder, there are four java files and one form file:<\/p>\n<h4>Main.java<\/h4>\n<p>In the Main class, we call the invokeLater() method of java.awt.EventQueue class and inside the run() method we create the object of Gph class and call its setVisible() method and pass true in it.<\/p>\n<h4>GfhWorkingDlg.java<\/h4>\n<p>This class extends the predefined class javax.swing.JDialog and implements the interface GphGuiConstants.There are two parameterized constructors. We create a thread to compress or decompress. This class basically performs the actions after clicking the button and shows the progress bar of processing.<\/p>\n<h4>GphGuiConstants.java<\/h4>\n<p>This interface has two String arrays &#8211; one for algorithms names and other for extensions. We have also defined some final variables with an initial value.<\/p>\n<h4>Gph.form<\/h4>\n<p>This is an xml file that defines all the properties of the components with their dimensions.<\/p>\n<h4>Gph.java<\/h4>\n<p>This class imports the java.awt.Color class and creates the layout of the application interface. We call the initComponents() methods in which we have created the whole frame using different components of javax.swing package.<\/p>\n<h3>Executing the project<\/h3>\n<p>To run this project in your system you need to import the wingph Source Code folder, then run the Main.java file, then the output window will appear.<\/p>\n<p><strong>Steps to run the project<\/strong><\/p>\n<p>1. When you run the Main.java file, you will see following window:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-home.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78842\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-home.png\" alt=\"project home\" width=\"442\" height=\"521\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-home.png 442w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-home-255x300.png 255w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-home-127x150.png 127w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><\/a><\/p>\n<p>2. Click the Browse button:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78843\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse2.png\" alt=\"browse\" width=\"502\" height=\"365\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse2.png 502w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse2-300x218.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse2-150x109.png 150w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/a><\/p>\n<p>3. Select the file you want to compress<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-select.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78844\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-select.png\" alt=\"browse select\" width=\"502\" height=\"365\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-select.png 502w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-select-300x218.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-select-150x109.png 150w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/a><\/p>\n<p>4. Now, select the compression algorithm:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/select-compression-algo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78846\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/select-compression-algo.png\" alt=\"select compression algo\" width=\"442\" height=\"521\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/select-compression-algo.png 442w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/select-compression-algo-255x300.png 255w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/select-compression-algo-127x150.png 127w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><\/a><\/p>\n<p>5. Choose the destination folder:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-destination.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78847\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-destination.png\" alt=\"browse destination\" width=\"502\" height=\"365\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-destination.png 502w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-destination-300x218.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/browse-destination-150x109.png 150w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/a><\/p>\n<p>6. Click the Ok button:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78849\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/output.png\" alt=\"output\" width=\"442\" height=\"521\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/output.png 442w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/output-255x300.png 255w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/output-127x150.png 127w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><\/a><\/p>\n<p>7. Now, we can see that in our folder, the zip file has been saved:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-zip-created.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78850\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-zip-created.png\" alt=\"project zip created\" width=\"1920\" height=\"1030\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-zip-created.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-zip-created-300x161.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-zip-created-1024x549.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-zip-created-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-zip-created-768x412.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-zip-created-1536x824.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/project-zip-created-520x279.png 520w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>From this project, you can easily reduce the large size file into a file of smaller size using compression and send them easily over the network. We can also decompress the compressed file to get the original file and the receiver\u2019s end. There are four algorithms used in this process. And various interfaces and classes of Swing and AWT packages are used to create the layout.<\/p>\n<p><b>What Next?<\/b><\/p>\n<p>It&#8217;s time to prepare for the interview: <a href=\"https:\/\/data-flair.training\/blogs\/java-interview-questions\/\">Top interview question and answers<\/a> to crack your next interview<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1058,&quot;href&quot;:&quot;https:\\\/\\\/users.cs.cf.ac.uk\\\/Dave.Marshall\\\/Multimedia\\\/node214.html&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20250422195212\\\/https:\\\/\\\/users.cs.cf.ac.uk\\\/Dave.Marshall\\\/Multimedia\\\/node214.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-09 00:18:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-16 07:34:46&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-20 08:26:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-25 13:48:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-29 18:59:21&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-02 11:38:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-06 13:42:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-12 12:04:59&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-01-16 06:06:04&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-01-27 05:01:59&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-01-30 19:07:21&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-03 16:04:01&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-10 16:38:17&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-23 06:59:36&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-27 16:02:01&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-03 09:19:39&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-03-11 17:45:42&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-16 10:12:35&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-20 09:25:46&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-03-24 06:05:56&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-27 11:13:19&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-02 12:10:42&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-08 09:25:00&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-11 15:47:07&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 14:52:31&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-21 03:27:34&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-24 03:43:53&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-28 05:07:59&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-05-01 07:22:07&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-05-04 10:36:08&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-05-08 20:06:05&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-05-12 01:41:26&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-05-21 13:44:09&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-05-26 02:53:55&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-06-09 09:28:44&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-09 09:28:44&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java Project &#8211; Compression and Decompression This is a Java project for beginners, implement your learnings on real-time projects.\u00a0Just theoretical knowledge is not sufficient, you have to work on real-time projects. In this article,&#46;&#46;&#46;<\/p>\n","protected":false},"author":7,"featured_media":78854,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[22478,22479,22481,22480],"class_list":["post-78834","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-compression-decompression-project","tag-java-project","tag-java-project-for-beginners","tag-java-project-with-source-code"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java Project - Compression and Decompression [Source Code Included] - DataFlair<\/title>\n<meta name=\"description\" content=\"Data Compression and Decompression - this java project aims at compressing &amp; decompressing different types of files stored in our system.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Project - Compression and Decompression [Source Code Included] - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Data Compression and Decompression - this java project aims at compressing &amp; decompressing different types of files stored in our system.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-01T10:20:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-07-01T12:19:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Project - Compression and Decompression [Source Code Included] - DataFlair","description":"Data Compression and Decompression - this java project aims at compressing & decompressing different types of files stored in our system.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/","og_locale":"en_US","og_type":"article","og_title":"Java Project - Compression and Decompression [Source Code Included] - DataFlair","og_description":"Data Compression and Decompression - this java project aims at compressing & decompressing different types of files stored in our system.","og_url":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-07-01T10:20:16+00:00","article_modified_time":"2020-07-01T12:19:29+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd"},"headline":"Java Project &#8211; Compression and Decompression [Source Code Included]","datePublished":"2020-07-01T10:20:16+00:00","dateModified":"2020-07-01T12:19:29+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/"},"wordCount":2090,"commentCount":5,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression.jpg","keywords":["compression decompression project","java project","java project for beginners","java project with source code"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/","url":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/","name":"Java Project - Compression and Decompression [Source Code Included] - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression.jpg","datePublished":"2020-07-01T10:20:16+00:00","dateModified":"2020-07-01T12:19:29+00:00","description":"Data Compression and Decompression - this java project aims at compressing & decompressing different types of files stored in our system.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/java-project-compression-decompression.jpg","width":1200,"height":628,"caption":"java project compression decompression"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/java-project-compression-decompression\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Java Project &#8211; Compression and Decompression [Source Code Included]"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team specializes in creating clear, actionable content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Backed by industry expertise, we make learning easy and career-oriented for beginners and pros alike.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam3\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/78834","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=78834"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/78834\/revisions"}],"predecessor-version":[{"id":78896,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/78834\/revisions\/78896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/78854"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=78834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=78834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=78834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}