import java.io.*;

public class FileApp {

private FileInputStream in;
private String fileName;

public FileApp(String fileName){
    this.fileName=fileName;
    doit();
}

public void doit(){

 try{
    /* when we attempt to instantiate the input stream here, the
     * constructor will call the SecurityManager, which will call
     * the AccessController, which will check with the current
     * Policy.
     */

    File f=new File(fileName);
    if(f.exists()){
        in=new FileInputStream(f);
    }

    /* Read the file into the an array of bytes and print it out
     */

    byte [] data=new byte[(int)f.length()];
    in.read(data);
    String s=new String(data);
    System.out.println(s);

 }
 catch(IOException ex){
    ex.printStackTrace();
 }
 catch(SecurityException ex){

    /* The AccessControlException thrown by the AccessController is a
     * subclass of SecurityException, so this will catch either one
     */

    ex.printStackTrace();
 }
}

public void destroy(){
    System.exit(0);
}

public static void main (String args[]){
    if(args.length<1){
        System.err.println("Usage: java FileApplet ");
        System.exit(1);
    }

    new FileApp(args[0]);
}

} // end FileApplet