-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecompression_3.java
71 lines (56 loc) · 1.5 KB
/
Decompression_3.java
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Scanner;
public class Decompression_3 {
HashMap<Character, String> directory = new HashMap<Character, String>();
HashMap<String, Character> reversed = new HashMap<String, Character>();
public void decompress() throws IOException {
BufferedWriter decompression = new BufferedWriter(new FileWriter("DecompressedMap"));
Character key = null;
String code = "";
int position = 1;
boolean t = false;
boolean d = false;
BufferedReader readmap = new BufferedReader(new FileReader("Map"));
for(int c = readmap.read(); c!= -1; c= readmap.read()) {
if(position == 1) {
key = (char) readmap.read();
//System.out.print(key);
position++;
d = true;
continue;
}
if(c == 44 && readmap.read()==32) {
c = readmap.read();
//System.out.println((char) c);
t = true;
d = false;
directory.put(key, code);
}
if(d) {
if(c == 61) {
c = readmap.read();
}
code += (char) c;
}
if(t) {
key = (char) c;
d = true;
t = false;
code = "";
}
}
System.out.println(directory.toString());
}
public static void main(String[] args) throws IOException {
Decompression_3 test = new Decompression_3();
test.decompress();
}
}