public static InputStream openStream(final URL url) throws IOException { try { return (InputStream) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return url.openStream(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getException(); } }
public static InputStream getResourceAsStream(final Class c, final String name) throws IOException { try { return (InputStream) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return c.getResourceAsStream(name); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getException(); } }