我目前的代码是
import java.io.*;
import java.security.acl.NotOwnerException;
import java.util.Scanner;
class Main {
public static void main(String args[])
{
System.out.print("Enter username: ");
Scanner scanner = new Scanner(System.in);
String username = scanner.nextLine();
System.out.print("Enter email: ");
Scanner scanner2 = new Scanner(System.in);
String email = scanner.nextLine();
System.out.print("Enter password: ");
Scanner scanner3 = new Scanner(System.in);
String password = scanner.nextLine();
try(FileWriter fw = new FileWriter("passwords.txt", true);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter out = new PrintWriter(bw))
{
out.print(username);
out.print(":");
out.print(email);
out.print(":");
out.print(password);
out.println("");
} catch (IOException e) {
//exception handling left as an exercise for the reader
}
}
}
我想要如果 String email != 以 @gmail.com 或 @yahoo.com 等结尾。但也要求他们的名字只能是数字和字母。我还想要求用户拥有超过 5 个字符但少于 15 个字符的密码,同时也只允许使用字母和数字。我还希望用户名超过 3 个字符且少于 13 个。同时也只有数字和字母。
慕的地10843
炎炎设计
相关分类