package com.jytnn.bean;
import java.io.Serializable;
public class Info implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1486080655514591743L;
}
package com.jytnn.bean;
/**
* @author wuxif_000 车型
*
*/
public class CarStyle extends Info{
/**
*
*/
private static final long serialVersionUID = 1L;
private String truckModel;
private Integer truckCode;
public String getTruckModel() {
return truckModel;
}
public void setTruckModel(String truckModel) {
this.truckModel = truckModel;
}
public Integer getTruckCode() {
return truckCode==null?0:truckCode;
}
public void setTruckCode(Integer truckCode) {
this.truckCode = truckCode;
}
@Override
public String toString() {
return "CarStyle [truckModel=" + truckModel + ", truckCode="
+ truckCode + "]";
}
}
CarStyle carStyle = new CarStyle();
carStyle.setTruckCode(110);
carStyle.setTruckModel("本田");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
objectOutputStream.writeObject(carStyle);
//TODO 分割线...........
byte[] byteArray = byteArrayOutputStream.toByteArray();
String encodeToString = Base64.encodeToString(byteArray, Base64.DEFAULT);
byteArray = Base64.decode(encodeToString, Base64.DEFAULT);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
Object readObject = objectInputStream.readObject();
System.out.println(readObject.toString());
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}