1 |
|
---|
2 | import java.io.ByteArrayOutputStream;
|
---|
3 | import java.io.File;
|
---|
4 | import java.io.FileInputStream;
|
---|
5 | import java.io.FileNotFoundException;
|
---|
6 | import java.io.FileOutputStream;
|
---|
7 | import java.io.IOException;
|
---|
8 | import java.io.OutputStream;
|
---|
9 |
|
---|
10 | import LZMA.LzmaInputStream;
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 | public class UnLzma {
|
---|
15 |
|
---|
16 | static int main2(String args[]) {
|
---|
17 | System.out.println("\nLZMA Decoder 4.02 Copyright (c) 1999-2004 Igor Pavlov 2004-06-10");
|
---|
18 | System.out.println("JAVA LZMA Decoder 0.90 myspace\n");
|
---|
19 |
|
---|
20 | if (args.length < 1 || args.length > 2) {
|
---|
21 | System.out.println("\nUsage: UnLzma file.lzma [outFile]\n");
|
---|
22 | return 1;
|
---|
23 | }
|
---|
24 | try {
|
---|
25 | File fileInput = new File(args[0]);
|
---|
26 | FileInputStream fileInputHandle = new FileInputStream(fileInput);
|
---|
27 | LzmaInputStream inputHandle = new LzmaInputStream(fileInputHandle);
|
---|
28 |
|
---|
29 | OutputStream outputHandle;
|
---|
30 | if (args.length > 1) {
|
---|
31 | outputHandle = new FileOutputStream(new File(args[1]));
|
---|
32 | } else {
|
---|
33 | outputHandle = new ByteArrayOutputStream();
|
---|
34 | }
|
---|
35 |
|
---|
36 | byte [] buffer = new byte [1<<14];
|
---|
37 |
|
---|
38 | int ret = inputHandle.read(buffer);
|
---|
39 | while (ret >= 1) {
|
---|
40 | outputHandle.write(buffer,0,ret);
|
---|
41 | ret = inputHandle.read(buffer);
|
---|
42 | }
|
---|
43 |
|
---|
44 | inputHandle.close();
|
---|
45 | outputHandle.close();
|
---|
46 |
|
---|
47 | outputHandle = null;
|
---|
48 | inputHandle = null;
|
---|
49 | return 0;
|
---|
50 | } catch (FileNotFoundException e) {
|
---|
51 | System.out.println(e.getMessage());
|
---|
52 | return 1;
|
---|
53 | } catch (IOException e) {
|
---|
54 | System.out.println(e.getMessage());
|
---|
55 | return 1;
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | public static void main(String[] args) {
|
---|
60 | long temps = System.currentTimeMillis();
|
---|
61 | int code = main2(args);
|
---|
62 | temps = System.currentTimeMillis() - temps;
|
---|
63 | System.out.println("time : " + temps + " ms");
|
---|
64 | System.exit(code);
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|