This repository has been archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunner.java
55 lines (47 loc) · 1.7 KB
/
Runner.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
import ie.gmit.encode.Encoder;
import ie.gmit.encode.EncoderFactory;
public class Runner {
public static void main(String[] args) throws Exception {
EncoderFactory ef = EncoderFactory.getInstance();
String s = "aaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb";
System.out.println("Before encoding: " + s);
Encoder en = ef.getEncoder("runlength"); // return a Runlength Encoder
// that
// can process String.
System.out.print("After Runlength encoding: ");
System.out.println(en.encode(s));
en = ef.getEncoder("Huffman"); // return a huffman Encoder that can
// process String.
System.out.print("After Huffman encoding: ");
System.out.println(en.encode(s));
en = ef.getEncoder("lempelziv"); // return a Runlength Encoder
// that
// can process String.
System.out.print("After LempelZiv LZ78 encoding: ");
System.out.println(en.encode(s));
en = ef.getEncoder("base64"); // return a Runlength Encoder
// that
// can process String.
System.out.print("After Base64 encoding: ");
System.out.println(en.encode(s));
System.out.println();
System.out.println();
en = ef.getFileEncoder("Huffman"); // return a Huffman Encoder that can
// // process Files.
try {
System.out.println("build.xml after huffman Encoding:");
System.out.println(en.encode("build.xml"));
System.out.println();
System.out.println();
} catch (Exception e) {
System.out.println(e.getMessage());
}
en = ef.getURLEncoder("Huffman"); // return a Huffman Encoder that can
try {
System.out.println("Google website after huffman Encoding:");
System.out.println(en.encode("http://www.google.ie/"));
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}