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