密码流 PassWord.java
生活随笔
收集整理的這篇文章主要介紹了
密码流 PassWord.java
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
PassWord.java
import java.io.*; public class PassWord {public static void main(String args[]) {boolean success=false;int count=0;Console cons;char[] passwd;cons = System.console();while(true) {System.out.print("輸入密碼:");passwd=cons.readPassword();count++;String password=new String(passwd);if (password.equals("tiger123")) {success=true;System.out.println("您第"+count+"次輸入的密碼正確!");break;}else {System.out.println("您第"+count+"次輸入的密碼"+password+"不正確");}if(count==3) {System.out.println("您"+count+"次輸入的密碼都不正確");System.exit(0);}}if(success) {File file=new File("score.txt");try {FileReader inOne=new FileReader(file);BufferedReader inTwo= new BufferedReader(inOne);String s=null;while((s=inTwo.readLine())!=null) {System.out.println(s);}inOne.close();inTwo.close();}catch(IOException exp){}}} }總結
以上是生活随笔為你收集整理的密码流 PassWord.java的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 从键盘输入一串连续的数字,判断输出是否为
- 下一篇: 汉字输入练习 TypeChinese.j