...
Code Block | ||
---|---|---|
| ||
private void privilegedMethod(final String filename) throws FileNotFoundException { final FileInputStream f[]={null}; try { FileInputStream fis = (FileInputStream) AccessController.doPrivileged( new PrivilegedExceptionAction() { public FileInputStream run() throws FileNotFoundException { f[0] =return new FileInputStream(filename); } } ); } catch (PrivilegedActionException e) { /* forward to handler and log */ } // do something with the file and then close it } |
...
Code Block | ||
---|---|---|
| ||
private void privilegedMethod(final String filename) throws FileNotFoundException { final FileInputStream f[]={null}; try { FileInputStream fis = (FileInputStream) AccessController.doPrivileged( new PrivilegedExceptionAction() { public FileInputStream run() throws FileNotFoundException { f[0] =return new FileInputStream("/usr/home/filename"); } } ); } catch (PrivilegedActionException e) { /* forward to handler and log */ } // do something with the file and then close it } |
...