我目前拥有的是这个
import java.io.*;
import java.security.acl.NotOwnerException;
import java.util.Scanner;
class Main {
public static void main(String args[])
{
try{
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();
// Create file
FileWriter fstream = new FileWriter("username.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write(username + ":" + email + ":" + password);
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}
但它一直在清除第一行。有没有办法让它每次都添加一行而不是清除第一行?如果可以,请有人帮助我。我正在为 java 使用 repl.it。
慕娘9325324
相关分类