Skip to content

Commit 362a102

Browse files
committed
move uncompressinputstream main into demo class
1 parent 43a533a commit 362a102

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package demo;
2+
3+
import java.io.FileInputStream;
4+
import java.io.InputStream;
5+
6+
import org.biojava.nbio.core.util.UncompressInputStream;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
10+
/**
11+
* Uncompresses a single tarred or zipped file, writing output to stdandard out
12+
*/
13+
public class UncompressFile {
14+
private final static Logger logger
15+
= LoggerFactory.getLogger(UncompressFile.class);
16+
17+
/**
18+
* Reads a file, uncompresses it, and sends the result to stdout.
19+
* Also writes trivial statistics to stderr.
20+
* @param args An array with one String element, the name of the file to read.
21+
* @throws IOException for any failure
22+
*/
23+
public static void main(String[] args) throws Exception {
24+
25+
if (args.length != 1) {
26+
logger.info("Usage: UncompressInputStream <file>");
27+
System.exit(1);
28+
}
29+
long beg = System.currentTimeMillis();
30+
31+
long tot;
32+
try (InputStream in = new FileInputStream(args[0]);
33+
) {
34+
tot = UncompressInputStream.uncompress(in, System.out);
35+
}
36+
37+
long end = System.currentTimeMillis();
38+
logger.info("Decompressed {} bytes", tot);
39+
logger.info("Time: {} seconds", (end - beg) / 1000);
40+
}
41+
42+
}

0 commit comments

Comments
 (0)