forked from Konloch/bytecode-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
54 lines (41 loc) · 1.44 KB
/
Main.java
File metadata and controls
54 lines (41 loc) · 1.44 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
42
43
44
45
46
47
48
49
50
51
52
53
54
package jd.cli;
import jd.cli.loader.DirectoryLoader;
import jd.cli.preferences.CommonPreferences;
import jd.cli.printer.text.PlainTextPrinter;
import jd.cli.util.ClassFileUtil;
import jd.core.Decompiler;
import jd.core.process.DecompilerImpl;
import java.io.File;
import java.io.PrintStream;
public class Main
{
/**
* @param args Path to java class
*/
public static void main(String[] args) {
if (args.length == 0) {
System.out.println("usage: ...");
} else {
try {
String pathToClass = args[0].replace('/', File.separatorChar).replace('\\', File.separatorChar);
String directoryPath = ClassFileUtil.ExtractDirectoryPath(pathToClass);
if (directoryPath == null)
return;
String internalPath = ClassFileUtil.ExtractInternalPath(directoryPath, pathToClass);
if (internalPath == null)
return;
CommonPreferences preferences = new CommonPreferences();
DirectoryLoader loader = new DirectoryLoader(new File(directoryPath));
//PrintStream ps = new PrintStream("test.html");
//HtmlPrinter printer = new HtmlPrinter(ps);
PrintStream ps = new PrintStream("test.txt");
PlainTextPrinter printer = new PlainTextPrinter(preferences, ps);
Decompiler decompiler = new DecompilerImpl();
decompiler.decompile(preferences, loader, printer, internalPath);
System.out.println("done.");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}