-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuffmanCoding.java
More file actions
36 lines (33 loc) · 1.13 KB
/
HuffmanCoding.java
File metadata and controls
36 lines (33 loc) · 1.13 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
import java.util.Scanner;
public class HuffmanCoding {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("");
Huffman huffman = new Huffman();
while (true) {
System.out.print("1. Encode file\n2. Decode file\n3. View tree\n4. Exit\n> ");
int choice = s.nextInt();
System.out.println();
switch (choice) {
case 1:
System.out.print("[Encode] Enter file path: ");
huffman.encodeFile(s.next());
break;
case 2:
System.out.print("[Decode] Enter file path: ");
huffman.decodeFile(s.next());
break;
case 3:
huffman.displayTree();
break;
case 4:
System.out.println("Bye");
s.close();
System.exit(0);
default:
System.out.println("Not an option!");
}
System.out.println();
}
}
}