コード例 #1
0
 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();
   }
 }
コード例 #2
0
 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();
   }
 }