⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 passwordsecuritymanager.java

📁 初期JAVA学习非常有用的资料。帮助深入了解API。特别是Applet。
💻 JAVA
字号:
import java.io.*;public class PasswordSecurityManager extends SecurityManager {    private String password;    public PasswordSecurityManager(String password) {        super();        this.password = password;    }    private boolean accessOK() {        int c;        DataInputStream in = new DataInputStream(System.in);        String response;        System.out.println("What's the secret password?");        try {            response = in.readLine();            if (response.equals(password))                return true;            else                return false;        } catch (IOException e) {            return false;        }    }    public void checkRead(FileDescriptor filedescriptor) {        if (!accessOK())            throw new SecurityException("Not a Chance!");    }    public void checkRead(String filename) {        if (!accessOK())            throw new SecurityException("No Way!");    }    public void checkRead(String filename, Object executionContext) {        if (!accessOK())            throw new SecurityException("Forget It!");    }    public void checkWrite(FileDescriptor filedescriptor) {        if (!accessOK())            throw new SecurityException("Not!");    }    public void checkWrite(String filename) {        if (!accessOK())            throw new SecurityException("Not Even!");    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -