package com.xagasoft.gats; import java.io.OutputStream; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; public class GatsOutputStream { private OutputStream os; public GatsOutputStream( OutputStream os ) { this.os = os; } public void writeObject( GatsObject obj ) throws java.io.IOException { ByteArrayOutputStream bos1 = new ByteArrayOutputStream(); obj.write( bos1 ); ByteArrayOutputStream bos2 = new ByteArrayOutputStream( 5 + bos1.size() ); DataOutputStream dos = new DataOutputStream( bos2 ); dos.writeByte( 1 ); dos.writeInt( bos1.size()+5 ); bos2.write( bos1.toByteArray() ); os.write( bos2.toByteArray() ); } };