在做ATM机的练习  不知道怎么把设置的账号和密码存入一个TXT文档里  

解决方案 »

  1.   

    ATM 文件操作 在google上百度一下
      

  2.   

    f(sign.equals("Registe")){
    if((file.length())==0){ String str=br.readLine();
    String str1=br.readLine();
    String str2=br.readLine();
    String str3=br.readLine();
    People p=new People();
    p.setBankNo(str);
    p.setPwd(str1);
    p.setName(str2);
    p.setPeId(str3);
    ar.put(str,p);
    FileOutputStream fos = new FileOutputStream(file);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(ar);
    oos.close();
                socket.close();
    }
    String str = br.readLine();
    String str1= br.readLine();
    String str2=br.readLine();
    String str3=br.readLine();
    FileInputStream fis = new FileInputStream(file);
    ObjectInputStream ois = new ObjectInputStream(fis);
            HashMap<String,People> al =(HashMap<String,People>) ois.readObject();
            People p=new People();
    p.setBankNo(str);
    p.setPwd(str1);
    p.setName(str2);
    p.setPeId(str3); al.put(str,p); FileOutputStream fos = new FileOutputStream("Data.data");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(al);
        oos.close();
        ois.close();
        StringBuffer sb=new StringBuffer();
        Date da=new Date();
        sb.append(str).append("用户注册的时间:").append((data.format(da)).toString());
        pr.println(sb.toString());     fk.println("zhuce");
    }
    就是这样子将密码和用户名写入到txt文件中的,流(thread)输入输出流。
      

  3.   

    在控制台中出现java.io.IOException: Stream closed
    这个是什么地方有问题