aboutsummaryrefslogtreecommitdiff
path: root/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'java/com')
-rw-r--r--java/com/xagasoft/gats/GatsObject.java1
-rw-r--r--java/com/xagasoft/gats/GatsOutputStream.java27
2 files changed, 27 insertions, 1 deletions
diff --git a/java/com/xagasoft/gats/GatsObject.java b/java/com/xagasoft/gats/GatsObject.java
index 852a18c..031dc90 100644
--- a/java/com/xagasoft/gats/GatsObject.java
+++ b/java/com/xagasoft/gats/GatsObject.java
@@ -15,6 +15,7 @@ public abstract class GatsObject
15 public abstract int getType(); 15 public abstract int getType();
16 16
17 public abstract void read( InputStream is, char cType ) throws java.io.IOException; 17 public abstract void read( InputStream is, char cType ) throws java.io.IOException;
18 public abstract void write( OutputStream os ) throws java.io.IOException;
18 19
19 public static GatsObject read( InputStream is ) throws java.io.IOException 20 public static GatsObject read( InputStream is ) throws java.io.IOException
20 { 21 {
diff --git a/java/com/xagasoft/gats/GatsOutputStream.java b/java/com/xagasoft/gats/GatsOutputStream.java
index 0ba452d..7bdfcde 100644
--- a/java/com/xagasoft/gats/GatsOutputStream.java
+++ b/java/com/xagasoft/gats/GatsOutputStream.java
@@ -1,9 +1,34 @@
1package com.xagasoft.gats; 1package com.xagasoft.gats;
2 2
3import java.io.InputStream;
4import java.io.OutputStream; 3import java.io.OutputStream;
4import java.io.ByteArrayOutputStream;
5import java.io.DataOutputStream;
5 6
6public class GatsOutputStream 7public class GatsOutputStream
7{ 8{
9 private OutputStream os;
10
11 public GatsOutputStream( OutputStream os )
12 {
13 this.os = os;
14 }
15
16 public void writeObject( GatsObject obj ) throws java.io.IOException
17 {
18 ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
19
20 obj.write( bos1 );
21
22 ByteArrayOutputStream bos2 = new ByteArrayOutputStream(
23 5 + bos1.size()
24 );
25
26 DataOutputStream dos = new DataOutputStream( bos2 );
27 dos.writeByte( 1 );
28 dos.writeInt( bos1.size()+5 );
29 bos2.write( bos1.toByteArray() );
30
31 os.write( bos2.toByteArray() );
32 }
8}; 33};
9 34