-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXZEncDemo.java
More file actions
41 lines (34 loc) · 1.14 KB
/
XZEncDemo.java
File metadata and controls
41 lines (34 loc) · 1.14 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
37
38
39
40
41
/*
* XZEncDemo
*
* Author: Lasse Collin <lasse.collin@tukaani.org>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
*/
import java.io.*;
import org.tukaani.xz.*;
/**
* Compresses a single file from standard input to standard ouput into
* the .xz file format.
* <p>
* One optional argument is supported: LZMA2 preset level which is an integer
* in the range [0, 9]. The default is 6.
*/
class XZEncDemo {
public static void main(String[] args) throws Exception {
LZMA2Options options = new LZMA2Options();
if (args.length >= 1)
options.setPreset(Integer.parseInt(args[0]));
System.err.println("Encoder memory usage: "
+ options.getEncoderMemoryUsage() + " KiB");
System.err.println("Decoder memory usage: "
+ options.getDecoderMemoryUsage() + " KiB");
XZOutputStream out = new XZOutputStream(System.out, options);
byte[] buf = new byte[8192];
int size;
while ((size = System.in.read(buf)) != -1)
out.write(buf, 0, size);
out.finish();
}
}