package com.abin.lee.servlet.important.type;
import java.io.Serializable;
public class LookValue implements Serializable{
/**
*
*/
private static final long serialVersionUID = -7746631577693804188L;
private int id;
private String name;
private transient String status;
public LookValue() {
super();
}
public LookValue(int id, String name, String status) {
super();
this.id = id;
this.name = name;
this.status = status;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
package com.abin.lee.servlet.important.type.test;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import org.junit.Test;
import com.abin.lee.servlet.important.type.LookValue;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
public class LookValueTest {
@Test
public void testLookValue() throws IOException, ClassNotFoundException{
LookValue look=new LookValue();
look.setId(1);
look.setName("abin");
look.setStatus("abing");
OutputStream out=new ByteOutputStream();
FileOutputStream file=new FileOutputStream("data.ser");
ObjectOutputStream obj=new ObjectOutputStream(file);
obj.writeObject(look);
obj.flush();
obj.close();
look=null;
FileInputStream input=new FileInputStream("data.ser");
ObjectInputStream oin=new ObjectInputStream(input);
look=(LookValue)oin.readObject();
oin.close();
System.out.println("id="+look.getId());
System.out.println("Name="+look.getName());
System.out.println("Status="+look.getStatus());
}
}
输出结果:
id=1
Name=abin
Status=null