static SecurityManager getSecurityManager()
描述 (Description)
java.lang.System.getSecurityManager()方法获取系统安全性接口。
声明 (Declaration)
以下是java.lang.System.getSecurityManager()方法的声明
public static SecurityManager getSecurityManager()
参数 (Parameters)
NA
返回值 (Return Value)
如果已为当前应用程序建立了安全管理器,则此方法返回安全管理器,否则返回null。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.System.getSecurityManager()方法的用法。
package com.iowiki;
import java.lang.*;
public class SystemDemo {
public static void main(String[] args) {
// prints the name of the Operating System
System.out.println(System.getProperty("os.name"));
SecurityManager s = System.getSecurityManager();
if(s == null) {
System.out.println("SecurityManager not been established..");
}
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
Linux
SecurityManager not been established..