0

我正在开发一个 java Web 应用程序,我想在其中使用属性类来存储用户名和密码,并将它们存储在 XYZ.properties 文件中。当我执行代码时,没有创建 XYZ.properties 文件。我想为每个用户注册添加用户名和密码到这个属性文件。所以我正在调用从 Servlet 创建属性文件的方法。

下面的代码片段

public  String insertUser(String uname,String password, Properties UserDetails) throws NullPointerException,IOException,FileNotFoundException
    {

        UserDetails.setProperty(uname, password);

        try {
            File file = new File("XYZ.properties");
            FileOutputStream  fw=new FileOutputStream (file);
            UserDetails.store(fw, "my:op");
4

0 回答 0