-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
45 lines (36 loc) · 1.69 KB
/
Main.java
File metadata and controls
45 lines (36 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public class Main {
public static void main(String[] args) {
String inpString = "This is a line written to the output file.\r\n" + //
"Another line.\r\n" + //
"Yet another line.";
System.out.println("Huffman coding:");
Huffman huffman = new Huffman(inpString);
String encodedText = huffman.encode();
System.out.println("\nThe encoded text is :");
System.out.println(encodedText);
System.out.println("\nThe following are the code for each letter: ");
huffman.printCodes();
String originalText = huffman.decode(encodedText);
System.out.println("\nThe decoded text: ");
System.out.println(originalText);
System.out.println("\nTree visualisation");
python python = new python(inpString);
python.Huffman_tree_visualisation();
CompressionRatio ratio = new CompressionRatio(8*originalText.length(),encodedText.length());
Double R=ratio.calculateRatio();
System.out.println("\nThe compression ratio: ");
System.out.println(R);
System.out.println("\n\nLZ77 encoding:");
LZ77 LZ77 = new LZ77(inpString,10,5);
System.out.println("\nThe encoded text is :");
System.out.println(LZ77.getcompressedData());
System.out.println("\nThe decoded text: ");
System.out.println(LZ77.getdecodedData());
System.out.println("\nLZW encoding:");
LZW LZW = new LZW(inpString);
System.out.println("\nThe encoded text is :");
System.out.println(LZW.getCompressed());
System.out.println("\nThe decoded text: ");
System.out.println(LZW.getDecompressed());
}
}