日期:2014-05-20 浏览次数:20919 次
public int Register(User u){
map=new HashMap<String, User>();
try {
dos=new ObjectOutputStream(new FileOutputStream("user.data"));
dis=new ObjectInputStream(new FileInputStream("user.data"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
map=(HashMap<String, User>)dis.readObject();
} catch (IOException e1) {
// TODO Auto-generated catch block
int a=map.size();
System.out.println(a+"!!!!!!!!!!!!!!!!!!!!");
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
map.put(u.getUname(), u);
try {
dos.writeObject(map);
dos.close();
dis.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return 1;
}