标签:edr value -- red port his 密码 lin mission
import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class BaseT { public static void main(String[] args) throws IOException { System.setSecurityManager(new mySecurityM("ABC","123")); File f=new File("E:\\Test.java"); DataInputStream fis=new DataInputStream(new FileInputStream(f)); String x=""; while((x=fis.readLine())!=null){ System.out.println(x); } fis.close(); } } //---------------------- import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class mySecurityM extends SecurityManager { private String upwd; private String unam; public mySecurityM(String unam,String upwd){ this.upwd=upwd; this.unam=unam; } public boolean okacess(){ System.out.println("请输入用户名和密码,用逗号隔开"); BufferedReader dis = new BufferedReader(new InputStreamReader(System.in)); try { String[] value=dis.readLine().split(","); if (value[0].equals(this.unam)&&value[1].equals(this.upwd)) return true; else return false; } catch (IOException e) { return false; } } public void checkRead(String file){ if(!okacess()){ throw new SecurityException("No Premission."); } } }
标签:edr value -- red port his 密码 lin mission
原文地址:https://www.cnblogs.com/rojas/p/8929134.html