-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxf.java
47 lines (38 loc) · 1.37 KB
/
xf.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
import FileProcess.Decompression;
import FileProcess.StopWatch;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
/**
* Class for command line interface of decompression
* <p>
* Usage: java xf InputFile OutputPath(optional)
*/
public final class xf {
// Command line main application function.
public static void main(String[] args) throws IOException {
StopWatch stopWatch = new StopWatch();
if (args.length == 0 || args.length > 2) {
System.err.println("Usage: java xf <source> [destination](optional)");
System.exit(1);
}
File inputFile = new File(args[0]);
if (!inputFile.isFile()) {
System.err.println("Usage: java xf <source> [dest](optional)");
System.err.println("<source> must be a file");
System.exit(1);
}
File outputRoot;
// Handle command line arguments
if (args.length == 1) {
outputRoot = inputFile.getParentFile();
} else {
outputRoot = new File(args[1]);
}
try (BufferedInputStream is = new BufferedInputStream(new FileInputStream(inputFile))) {
Decompression.decompress(outputRoot, is);
}
System.out.println("Decompression finished in " + stopWatch.getRunningSeconds() + " seconds");
}
}