Share_My_Sheet/src/br/edu/ufsj/sms/net/Message.java

27 lines
730 B
Java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package br.edu.ufsj.sms.net;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
*
* @author flavio
*/
public abstract class Message implements Serializable{
public byte[] toByteArray() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(baos);
out.writeObject(this);
out.flush();
return baos.toByteArray();
}
}