Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/io/FilePermission/m/p/App.java
41159 views
1
package p;
2
import java.io.InputStream;
3
import java.io.FileInputStream;
4
public class App {
5
public static void main(String[] args) throws Exception {
6
boolean f = true;
7
StringBuilder sb = new StringBuilder();
8
String expected = null;
9
for (String s: args) {
10
if (expected == null) {
11
expected = s;
12
} else if (s.equals("-")) {
13
f = false;
14
} else if (f) {
15
try (InputStream is = new FileInputStream(s)) {
16
is.readAllBytes();
17
sb.append('+');
18
} catch (SecurityException se) {
19
System.out.println(se);
20
sb.append('S');
21
} catch (Exception e) {
22
System.out.println(e);
23
sb.append('-');
24
}
25
} else {
26
try (InputStream is = App.class.getResourceAsStream(s)) {
27
is.readAllBytes();
28
sb.append('+');
29
} catch (NullPointerException npe) {
30
System.out.println(npe);
31
sb.append('0');
32
} catch (Exception e) {
33
System.out.println(e);
34
sb.append('-');
35
}
36
}
37
}
38
if (!sb.toString().equals(expected)) {
39
throw new Exception("Expected " + expected + ", actually " + sb);
40
} else {
41
System.out.println("OK");
42
}
43
}
44
}
45
46