...
Code Block | ||
---|---|---|
| ||
public static void readFont() throws FileNotFoundException { // Use own privilege to open the font file final String font_file = "fontfile"; try { final InputStream in = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() { public InputStream run() throws FileNotFoundException { return openFontFile(font_file); //call the privileged method here } }); // Perform other operations } catch (PrivilegedActionException exc) { Exception cause = exc.getException(); if (cause instanceof FileNotFoundException) { throw (FileNotFoundException)cause; } else { throw new Error("Unexpected exception type",cause); } } } |
...