Code example for FilePermission

Methods: newPermissionCollection

0
 
    } 
 
    static void tryFilePC() throws Exception { 
        try { 
            FilePermission p0 = new FilePermission("/home/foobar","read");
            PermissionCollection pc = p0.newPermissionCollection();
            pc.setReadOnly();   // this should lock out future adds
            // 
            FilePermission p1 = new FilePermission("/home/quux","read");
            pc.add(p1);
            throw new 
                Exception("Failed...FilePermission added to readonly FilePermissionCollection.");
 
        } catch (SecurityException se) {
            System.out.println("FilePermissionCollection passed");
        } 
    } 
 
    static void tryBasicPC() throws Exception { 
        try {