我希望將控制檯中的所有用戶輸入複製到.txt文件。 這是我的代碼,謝謝!所有從控制檯上的用戶輸入到.txt java
import java.util.Scanner;
import java.io.Console;
public class passwordDriver {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Console cnsl = null;
String alpha = null;
boolean checkPass = true;
// creates a console object
cnsl = System.console();
if (cnsl != null) {
/** // read line from the user input
alpha = cnsl.readLine("Name: ");
// prints
//System.out.println("Name is: " + alpha);
*/
}
while (checkPass) {
try{
// if console is not null
if (cnsl != null) {
//tell the user what the app does
System.out.println("Type your password and check how strong it is!");
// read password into the char array
char[] pwd = cnsl.readPassword("Password: ");
if (PassCheck.validatePassword(String.valueOf(pwd))) {
checkPass = false;
}
else {
System.out.println("Your password is invalid. ");
}
}
}catch(Exception ex){
// if any error occurs
ex.printStackTrace();
}
}
}
而是張貼的絨毛,你也可以使用該解釋發生了什麼問題的空間。 –
OP - 「我想製作一個密碼強度檢查器,它將密碼存儲到一個txt文件中。」這個粗略是強烈的。 – Jeutnarg