Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
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
bgColor#ccccff
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
}

...