├── Compressor-Decompressor
├── untitled
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── MANIFEST.MF
│ │ │ └── java
│ │ │ ├── GUI
│ │ │ ├── main.java
│ │ │ └── AppFrame.java
│ │ │ └── comp_decomp
│ │ │ ├── compressor.java
│ │ │ └── decompressor.java
│ ├── out
│ │ └── artifacts
│ │ │ └── untitled_jar
│ │ │ └── untitled.jar
│ └── pom.xml
├── src
│ ├── Main.java
│ └── main
│ │ └── java
│ │ ├── GUI
│ │ ├── main.java
│ │ └── AppFrame.java
│ │ └── comp_decomp
│ │ ├── compressor.java
│ │ └── decompressor.java
├── Image
│ ├── UI.jpg
│ ├── Compress.jpg
│ └── Decompress.jpg
├── target
│ └── classes
│ │ ├── GUI
│ │ ├── main.class
│ │ └── AppFrame.class
│ │ └── comp_decomp
│ │ ├── compressor.class
│ │ └── decompressor.class
├── out
│ └── artifacts
│ │ └── compressor_decompressor_jar
│ │ └── compressor_decompressor.jar
├── Compressor-Decompressor.iml
└── pom.xml
└── README.md
/Compressor-Decompressor/untitled/src/main/resources/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Main-Class: GUI.main
3 |
4 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/src/Main.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class Main {
4 | public static void main(String[] args) {
5 |
6 | }
7 | }
--------------------------------------------------------------------------------
/Compressor-Decompressor/Image/UI.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/navneet-chugh/Compresor_Decompressor/HEAD/Compressor-Decompressor/Image/UI.jpg
--------------------------------------------------------------------------------
/Compressor-Decompressor/Image/Compress.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/navneet-chugh/Compresor_Decompressor/HEAD/Compressor-Decompressor/Image/Compress.jpg
--------------------------------------------------------------------------------
/Compressor-Decompressor/Image/Decompress.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/navneet-chugh/Compresor_Decompressor/HEAD/Compressor-Decompressor/Image/Decompress.jpg
--------------------------------------------------------------------------------
/Compressor-Decompressor/target/classes/GUI/main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/navneet-chugh/Compresor_Decompressor/HEAD/Compressor-Decompressor/target/classes/GUI/main.class
--------------------------------------------------------------------------------
/Compressor-Decompressor/target/classes/GUI/AppFrame.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/navneet-chugh/Compresor_Decompressor/HEAD/Compressor-Decompressor/target/classes/GUI/AppFrame.class
--------------------------------------------------------------------------------
/Compressor-Decompressor/target/classes/comp_decomp/compressor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/navneet-chugh/Compresor_Decompressor/HEAD/Compressor-Decompressor/target/classes/comp_decomp/compressor.class
--------------------------------------------------------------------------------
/Compressor-Decompressor/target/classes/comp_decomp/decompressor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/navneet-chugh/Compresor_Decompressor/HEAD/Compressor-Decompressor/target/classes/comp_decomp/decompressor.class
--------------------------------------------------------------------------------
/Compressor-Decompressor/untitled/out/artifacts/untitled_jar/untitled.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/navneet-chugh/Compresor_Decompressor/HEAD/Compressor-Decompressor/untitled/out/artifacts/untitled_jar/untitled.jar
--------------------------------------------------------------------------------
/Compressor-Decompressor/untitled/src/main/java/GUI/main.java:
--------------------------------------------------------------------------------
1 | package GUI;
2 |
3 | public class main {
4 | public static void main(String[] args) {
5 | AppFrame frame = new AppFrame("Compressor-Decompressor");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/src/main/java/GUI/main.java:
--------------------------------------------------------------------------------
1 | package GUI;
2 |
3 |
4 | public class main {
5 | public static void main(String[] args) {
6 |
7 | AppFrame frame = new AppFrame("Compressor-Decompressor");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/out/artifacts/compressor_decompressor_jar/compressor_decompressor.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/navneet-chugh/Compresor_Decompressor/HEAD/Compressor-Decompressor/out/artifacts/compressor_decompressor_jar/compressor_decompressor.jar
--------------------------------------------------------------------------------
/Compressor-Decompressor/Compressor-Decompressor.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/untitled/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.example
8 | untitled
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 18
13 | 18
14 | UTF-8
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.example
8 | compressor_decompressor
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 18
13 | 18
14 | UTF-8
15 |
16 |
17 |
18 | org.jetbrains
19 | annotations
20 | RELEASE
21 | compile
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/src/main/java/comp_decomp/compressor.java:
--------------------------------------------------------------------------------
1 | package comp_decomp;
2 | import java.io.File;
3 | import java.io.FileInputStream;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.util.zip.GZIPOutputStream;
7 |
8 | public class compressor {
9 | public static void method(File file) throws IOException {
10 | String fileDirectory=file.getParent();
11 | FileInputStream fis = new FileInputStream(file);
12 | FileOutputStream fos = new FileOutputStream(fileDirectory+"/CompressesdFile.gz");
13 | GZIPOutputStream gzip = new GZIPOutputStream(fos);
14 |
15 | byte[] buffer = new byte[1024];
16 | int len;
17 | while((len=fis.read(buffer))!=-1){
18 | gzip.write(buffer,0,len);
19 | }
20 | gzip.close();
21 | fos.close();
22 | fis.close();
23 | }
24 |
25 | public static void main(String[] args) throws IOException {
26 | File path=new File("");
27 | method(path);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/untitled/src/main/java/comp_decomp/compressor.java:
--------------------------------------------------------------------------------
1 | package comp_decomp;
2 | import java.io.File;
3 | import java.io.FileInputStream;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.util.zip.GZIPOutputStream;
7 |
8 | public class compressor {
9 | public static void method(File file) throws IOException {
10 | String fileDirectory=file.getParent();
11 | FileInputStream fis = new FileInputStream(file);
12 | FileOutputStream fos = new FileOutputStream(fileDirectory+"/CompressesdFile.gz");
13 | GZIPOutputStream gzip = new GZIPOutputStream(fos);
14 |
15 | byte[] buffer = new byte[1024];
16 | int len;
17 | while((len=fis.read(buffer))!=-1){
18 | gzip.write(buffer,0,len);
19 | }
20 | gzip.close();
21 | fos.close();
22 | fis.close();
23 | }
24 |
25 | public static void main(String[] args) throws IOException {
26 | File path=new File("");
27 | method(path);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/src/main/java/comp_decomp/decompressor.java:
--------------------------------------------------------------------------------
1 | package comp_decomp;
2 | import java.io.File;
3 | import java.io.FileInputStream;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.util.zip.GZIPInputStream;
7 |
8 | public class decompressor {
9 | public static void method(File file) throws IOException {
10 | String fileDirectory = file.getParent();
11 |
12 | FileInputStream fis = new FileInputStream(file);
13 | GZIPInputStream gzip = new GZIPInputStream(fis);
14 | FileOutputStream fos = new FileOutputStream(fileDirectory + "/decompressedfile");
15 |
16 | byte[] buffer = new byte[1024];
17 | int len;
18 | while ((len = gzip.read(buffer)) != -1) {
19 | fos.write(buffer, 0, len);
20 | }
21 | gzip.close();
22 | fos.close();
23 | fis.close();
24 | }
25 | public static void main(String[] args) throws IOException {
26 | File path = new File("");
27 | method(path);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/untitled/src/main/java/comp_decomp/decompressor.java:
--------------------------------------------------------------------------------
1 | package comp_decomp;
2 | import java.io.File;
3 | import java.io.FileInputStream;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.util.zip.GZIPInputStream;
7 |
8 | public class decompressor {
9 | public static void method(File file) throws IOException {
10 | String fileDirectory = file.getParent();
11 |
12 | FileInputStream fis = new FileInputStream(file);
13 | GZIPInputStream gzip = new GZIPInputStream(fis);
14 | FileOutputStream fos = new FileOutputStream(fileDirectory + "/decompressedfile");
15 |
16 | byte[] buffer = new byte[1024];
17 | int len;
18 | while ((len = gzip.read(buffer)) != -1) {
19 | fos.write(buffer, 0, len);
20 | }
21 | gzip.close();
22 | fos.close();
23 | fis.close();
24 | }
25 | public static void main(String[] args) throws IOException {
26 | File path = new File("");
27 | method(path);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Compressor & Decompressor
2 | @author "Navneet Chugh"
3 |
4 | ### Introduction
5 | Objective of this project is to reduce the number of bits needed to represent data through compression technique. This project will only use lossless conversion to ensure no data loss occurs during compression. Benefits of compression include saving storage space, speeding up file transfers, and reducing storage hardware and network bandwidth costs. Lossless compression is essential to ensure data is not lost while compressing. In this project, we will ensure that our compressed files can be restored to their original form.
6 |
7 | ### Tech Stack
8 | - :red_circle: Java
9 | - :red_circle: Swing
10 | - :red_circle: AWT
11 |
12 | ### Project snips
13 | 
14 | 
15 | 
16 |
17 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/src/main/java/GUI/AppFrame.java:
--------------------------------------------------------------------------------
1 | package GUI;
2 |
3 | import comp_decomp.compressor;
4 | import comp_decomp.decompressor;
5 | import javax.swing.*;
6 | import java.awt.*;
7 | import java.awt.event.ActionEvent;
8 | import java.awt.event.ActionListener;
9 | import java.io.File;
10 |
11 | public class AppFrame extends JFrame implements ActionListener {
12 |
13 | JButton compressButton;
14 | JButton decompressButton;
15 |
16 | AppFrame(String name){
17 | this.setTitle(name);
18 |
19 | Container c = this.getContentPane();
20 | c.setLayout(new BorderLayout());
21 |
22 | JPanel headingPanel = new JPanel(); // Create a panel for the heading
23 | headingPanel.setBackground(new Color(16, 13, 13)); // Set background color
24 | headingPanel.setPreferredSize(new Dimension(getWidth(), 80)); // Set preferred size
25 |
26 | JLabel headingLabel = new JLabel("Compressor-Decompressor");
27 | headingLabel.setFont(new Font("Arial", Font.BOLD, 24));
28 | headingLabel.setForeground(Color.white); // Set text color
29 | headingPanel.add(headingLabel); // Add the heading label to the heading panel
30 |
31 | JPanel buttonPanel = new JPanel(); // Create a panel for the buttons
32 | buttonPanel.setBackground(new Color(18, 18, 21)); // Set background color
33 | buttonPanel.setPreferredSize(new Dimension(getWidth(), 120)); // Set preferred size
34 |
35 | compressButton = new JButton("Select file to compress");
36 | decompressButton = new JButton("Select file to decompress");
37 | compressButton.setBackground(new Color(23, 21, 21)); // Set button background color
38 | decompressButton.setBackground(new Color(20, 20, 21)); // Set button background color
39 | compressButton.setForeground(Color.white); // Set button text color
40 | decompressButton.setForeground(Color.white); // Set button text color
41 |
42 | buttonPanel.add(compressButton);
43 | buttonPanel.add(decompressButton);
44 |
45 | c.add(headingPanel, BorderLayout.NORTH); // Add the heading panel to the top
46 | c.add(buttonPanel, BorderLayout.CENTER); // Add the button panel to the center
47 |
48 | compressButton.addActionListener(this);
49 | decompressButton.addActionListener(this);
50 |
51 | this.setSize(500, 300);
52 | this.getContentPane().setBackground(Color.BLACK); // Set background color for the frame
53 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
54 | this.setLocationRelativeTo(null); // Center the frame on the screen
55 | this.setVisible(true);
56 |
57 | }
58 |
59 | @Override
60 | public void actionPerformed(ActionEvent e) {
61 | if(e.getSource()==compressButton){
62 | JFileChooser filechooser = new JFileChooser();
63 | int response =filechooser.showSaveDialog(null);
64 | if(response==JFileChooser.APPROVE_OPTION){
65 | File file = new File(filechooser.getSelectedFile().getAbsolutePath());
66 | System.out.print(file);
67 | try{
68 | compressor.method(file);
69 | }
70 | catch(Exception ee){
71 | JOptionPane.showMessageDialog(null, ee.toString());
72 | }
73 | }
74 | }
75 | if(e.getSource()==decompressButton){
76 | JFileChooser filechooser = new JFileChooser();
77 | int response =filechooser.showSaveDialog(null);
78 | if(response==JFileChooser.APPROVE_OPTION){
79 | File file = new File(filechooser.getSelectedFile().getAbsolutePath());
80 | System.out.print(file);
81 | try{
82 | decompressor.method(file);
83 | }
84 | catch(Exception ee){
85 | JOptionPane.showMessageDialog(null, ee.toString());
86 | }
87 | }
88 | }
89 | }
90 | }
91 |
92 |
--------------------------------------------------------------------------------
/Compressor-Decompressor/untitled/src/main/java/GUI/AppFrame.java:
--------------------------------------------------------------------------------
1 | package GUI;
2 |
3 | import comp_decomp.compressor;
4 | import comp_decomp.decompressor;
5 | import javax.swing.*;
6 | import java.awt.*;
7 | import java.awt.event.ActionEvent;
8 | import java.awt.event.ActionListener;
9 | import java.io.File;
10 |
11 | public class AppFrame extends JFrame implements ActionListener {
12 |
13 | JButton compressButton;
14 | JButton decompressButton;
15 |
16 | public AppFrame(String name){
17 | this.setTitle(name);
18 |
19 | Container c = this.getContentPane();
20 | c.setLayout(new BorderLayout());
21 |
22 | JPanel headingPanel = new JPanel(); // Create a panel for the heading
23 | headingPanel.setBackground(new Color(63, 81, 181)); // Set background color
24 | headingPanel.setPreferredSize(new Dimension(getWidth(), 80)); // Set preferred size
25 |
26 | JLabel headingLabel = new JLabel("Compressor-Decompressor");
27 | headingLabel.setFont(new Font("Arial", Font.BOLD, 24));
28 | headingLabel.setForeground(Color.white); // Set text color
29 | headingPanel.add(headingLabel); // Add the heading label to the heading panel
30 |
31 | JPanel buttonPanel = new JPanel(); // Create a panel for the buttons
32 | buttonPanel.setBackground(new Color(63, 81, 181)); // Set background color
33 | buttonPanel.setPreferredSize(new Dimension(getWidth(), 120)); // Set preferred size
34 |
35 | compressButton = new JButton("Select file to compress");
36 | decompressButton = new JButton("Select file to decompress");
37 | compressButton.setBackground(new Color(63, 81, 181)); // Set button background color
38 | decompressButton.setBackground(new Color(63, 81, 181)); // Set button background color
39 | compressButton.setForeground(Color.white); // Set button text color
40 | decompressButton.setForeground(Color.white); // Set button text color
41 |
42 | buttonPanel.add(compressButton);
43 | buttonPanel.add(decompressButton);
44 |
45 | c.add(headingPanel, BorderLayout.NORTH); // Add the heading panel to the top
46 | c.add(buttonPanel, BorderLayout.CENTER); // Add the button panel to the center
47 |
48 | compressButton.addActionListener(this);
49 | decompressButton.addActionListener(this);
50 |
51 | this.setSize(500, 300);
52 | this.getContentPane().setBackground(Color.white); // Set background color for the frame
53 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
54 | this.setLocationRelativeTo(null); // Center the frame on the screen
55 | this.setVisible(true);
56 |
57 | }
58 | //Overriding the actionPerformed method form the actionlistener interface
59 | @Override
60 | public void actionPerformed(ActionEvent e) {
61 | if(e.getSource()==compressButton){
62 | JFileChooser filechooser = new JFileChooser();
63 | int response =filechooser.showSaveDialog(null);
64 | if(response==JFileChooser.APPROVE_OPTION){
65 | File file = new File(filechooser.getSelectedFile().getAbsolutePath());
66 | System.out.print(file);
67 | try{
68 | compressor.method(file);
69 | }
70 | catch(Exception ee){
71 | JOptionPane.showMessageDialog(null, ee.toString());
72 | }
73 | }
74 | }
75 | if(e.getSource()==decompressButton){
76 | JFileChooser filechooser = new JFileChooser();
77 | int response =filechooser.showSaveDialog(null);
78 | if(response==JFileChooser.APPROVE_OPTION){
79 | File file = new File(filechooser.getSelectedFile().getAbsolutePath());
80 | System.out.print(file);
81 | try{
82 | decompressor.method(file);
83 | }
84 | catch(Exception ee){
85 | JOptionPane.showMessageDialog(null, ee.toString());
86 | }
87 | }
88 | }
89 | }
90 | }
91 |
92 |
--------------------------------------------------------------------------------