1. import java.io.*;
     2. import java.security.*;
     3. 
     4. class MyPrivilegedExceptionAction implements PrivilegedExceptionAction
     5. {
     6.    public Object run() throws FileNotFoundException
     7.    {
     8.       FileInputStream fis = new FileInputStream("C:\\AUTOEXEC.BAT");
     9.       try
    10.       {
    11.          int count = 0;
    12.          while (fis.read() != -1)
    13.             count++;
    14.          System.out.println("Hi! We counted " + count + " chars.");
    15.       }
    16.       catch (Exception e)
    17.       {
    18.          System.out.println("Exception " + e);
    19.       }
    20.       return null;
    21.    }
    22. }
    23. 
    24. public class CountFile1
    25. {
    26.    public CountFile1() throws FileNotFoundException
    27.    {
    28.       try
    29.       {
    30.          AccessController.doPrivileged(
    31. 			 new MyPrivilegedExceptionAction());
    32.       }
    33.       catch (PrivilegedActionException e)
    34.       {
    35.          throw (FileNotFoundException) e.getException();
    36.       }
    37.    }
    38. }