import java.util.Date;
public class GuestLoggingInfo implements java.io.Serializable
{
private Date loggingDate = new Date();
private String uid;
private transient String pwd;
GuestLoggingInfo()
{
uid = "guest";
pwd = "guest";
}
public String toString()
{
return uid + pwd;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
}
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
public class Test5 {
public static void main(String[] args) throws IOException {
GuestLoggingInfo guest = new GuestLoggingInfo();
FileOutputStream os = new FileOutputStream("fileName.dat");
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(guest);
}
}
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
public class Test6 {
public static void main(String[] args) throws IOException, ClassNotFoundException {
FileInputStream fis = new FileInputStream("fileName.dat");
ObjectInputStream ois = new ObjectInputStream(fis);
GuestLoggingInfo guest = (GuestLoggingInfo)ois.readObject();
System.out.println(guest.getPwd());
}
}