/
githubmirror
/
jdk22
Обзор
Документация
Войти
/
githubmirror
/
jdk22
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/jdk/java/io/FilePermission/m/p/App.java
44 строки
1 KB
Erik Joelsson
8187443: Forest Consolidation: Move files to unified layout
12 сен 2017, 20:03
12 сен 2017, 20:03
3789983
Код
Авторство
О чём код?
package p; import java.io.InputStream; import java.io.FileInputStream; public class App { public static void main(String[] args) throws Exception { boolean f = true; StringBuilder sb = new StringBuilder(); String expected = null; for (String s: args) { if (expected == null) { expected = s; } else if (s.equals("-")) { f = false; } else if (f) { try (InputStream is = new FileInputStream(s)) { is.readAllBytes(); sb.append('+'); } catch (SecurityException se) { System.out.println(se); sb.append('S'); } catch (Exception e) { System.out.println(e); sb.append('-'); } } else { try (InputStream is = App.class.getResourceAsStream(s)) { is.readAllBytes(); sb.append('+'); } catch (NullPointerException npe) { System.out.println(npe); sb.append('0'); } catch (Exception e) { System.out.println(e); sb.append('-'); } } } if (!sb.toString().equals(expected)) { throw new Exception("Expected " + expected + ", actually " + sb); } else { System.out.println("OK"); } } }