package J20250725;

import java.io.FileWriter;
import java.io.IOException;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo11_RegisterUser
 * @description
 * @create 2025/7/25
 */
public class Demo11_RegisterUser {
    /**
     * 用户注册
     * @param username  用户名
     * @param password  密码
     * @return
     */
    public static boolean registerUser(String username,String password){
        FileWriter fw=null;
        try {
            fw=new FileWriter("D:/user.txt",true);
            fw.write(username);
            fw.write("\r\n");
            fw.write(password);
            //刷新流，写完了数据，手动刷新
            fw.flush();

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return false;
    }

    public static void main(String[] args) {
        registerUser("zhangsan","123456");
    }
}
