-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathApp.java
More file actions
40 lines (31 loc) · 1.11 KB
/
Copy pathApp.java
File metadata and controls
40 lines (31 loc) · 1.11 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
package org.example;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.example.analyzer.Analyzer;
import org.example.analyzer.JarMetrics;
public class App {
private static final String defaultJar = "src/main/resources/sample.jar";
private static final String defaultOutput = "./output.json";
public static void main(String[] args) throws IOException {
String jar = defaultJar;
String outFile = defaultOutput;
if (args.length > 0) {
jar = args[0];
}
if (args.length > 1) {
outFile = args[1];
}
JarMetrics metrics = new Analyzer().analyze(jar);
ObjectMapper mapper = new ObjectMapper();
byte[] stringifiedMetrics = mapper.writeValueAsBytes(metrics);
System.out.write(stringifiedMetrics);
System.out.println();
if (outFile != null) {
try (OutputStream outputStream = new FileOutputStream(outFile)) {
outputStream.write(stringifiedMetrics);
}
}
}
}