import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class MessageContainer implements Serializable {
// 管道对通告
private byte[] pairOfPipesAdv;
//
private String whatToDo;
// 我的ID
private String userID;
// 文件名
private String filePath;
/**
* @return the filePath
*/
public String getFilePath() {
return filePath;
}
/**
* @param filePath the filePath to set
*/
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public MessageContainer() {
pairOfPipesAdv = null;
whatToDo = null;
userID = null;
}
public void setpairOfPipesAdv(byte pairOfPipesAdv[]) {
this.pairOfPipesAdv = pairOfPipesAdv;
}
public byte[] getpairOfPipesAdv() {
return pairOfPipesAdv;
}
public void setwhatToDo(String whatToDo) {
this.whatToDo = whatToDo;
}
public String getwhatToDo() {
return whatToDo;
}
/**
* @return the userID
*/
public String getUserID() {
return userID;
}
/**
* @param userID the userID to set
*/
public void setUserID(String userID) {
this.userID = userID;
}
/**
* 序列化消息容器
*/
public static byte[] serializeMessageConatiner(MessageContainer messageContainer) {
byte serializedObject[] = null;
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(messageContainer);
out.close();
serializedObject = bos.toByteArray();
} catch (Exception e) {
e.printStackTrace();
}
return serializedObject;
}
/**
* 反序列化消息容器
*/
public static MessageContainer deserializeMessageConatiner(byte serializedMessageContainer[]) {
MessageContainer messageContainer = null;
try {
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(serializedMessageContainer));
messageContainer = (MessageContainer) in.readObject();
} catch (Throwable t) {
t.printStackTrace();
}
return messageContainer;
}
}
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class MessageContainer implements Serializable {
// 管道对通告
private byte[] pairOfPipesAdv;
//
private String whatToDo;
// 我的ID
private String userID;
// 文件名
private String filePath;
/**
* @return the filePath
*/
public String getFilePath() {
return filePath;
}
/**
* @param filePath the filePath to set
*/
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public MessageContainer() {
pairOfPipesAdv = null;
whatToDo = null;
userID = null;
}
public void setpairOfPipesAdv(byte pairOfPipesAdv[]) {
this.pairOfPipesAdv = pairOfPipesAdv;
}
public byte[] getpairOfPipesAdv() {
return pairOfPipesAdv;
}
public void setwhatToDo(String whatToDo) {
this.whatToDo = whatToDo;
}
public String getwhatToDo() {
return whatToDo;
}
/**
* @return the userID
*/
public String getUserID() {
return userID;
}
/**
* @param userID the userID to set
*/
public void setUserID(String userID) {
this.userID = userID;
}
/**
* 序列化消息容器
*/
public static byte[] serializeMessageConatiner(MessageContainer messageContainer) {
byte serializedObject[] = null;
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(messageContainer);
out.close();
serializedObject = bos.toByteArray();
} catch (Exception e) {
e.printStackTrace();
}
return serializedObject;
}
/**
* 反序列化消息容器
*/
public static MessageContainer deserializeMessageConatiner(byte serializedMessageContainer[]) {
MessageContainer messageContainer = null;
try {
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(serializedMessageContainer));
messageContainer = (MessageContainer) in.readObject();
} catch (Throwable t) {
t.printStackTrace();
}
return messageContainer;
}
}
——————————————————————————————————
傲轩游戏网
傲轩游戏网