本文整理汇总了Java中java.io.FilePermission.newPermissionCollection方法的典型用法代码示例。如果您正苦于以下问题:Java FilePermission.newPermissionCollection方法的具体用法?Java FilePermission.newPermissionCollection怎么用?Java FilePermission.newPermissionCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.FilePermission
的用法示例。
在下文中一共展示了FilePermission.newPermissionCollection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryFilePC
import java.io.FilePermission; //导入方法依赖的package包/类
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");
}
}
示例2: tryFilePC
import java.io.FilePermission; //导入方法依赖的package包/类
static void tryFilePC() throws Exception {
try {
FilePermission p0 = new FilePermission("/tmp/foobar","read");
PermissionCollection pc = p0.newPermissionCollection();
pc.setReadOnly(); // this should lock out future adds
//
FilePermission p1 = new FilePermission("/tmp/quux","read");
pc.add(p1);
throw new
Exception("Failed...FilePermission added to readonly FilePermissionCollection.");
} catch (SecurityException se) {
System.out.println("FilePermissionCollection passed");
}
}
示例3: MP
import java.io.FilePermission; //导入方法依赖的package包/类
MP(String f) {
FilePermission p = new FilePermission(f, "read");
pc = p.newPermissionCollection();
pc.add(p);
}