diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-04-21 17:57:04 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-04-21 17:57:04 +0000 |
commit | 757042bd5748389d3b984bbff72c2b2e3d9d5dd0 (patch) | |
tree | 6e9c18d4dc5240e6710b0a44c44c852e09cc070a /java/com/xagasoft/gats/GatsOutputStream.java | |
parent | 4fb4a056c52d3a96b6ef9a4ceb5ce39fc716a9aa (diff) | |
download | libgats-757042bd5748389d3b984bbff72c2b2e3d9d5dd0.tar.gz libgats-757042bd5748389d3b984bbff72c2b2e3d9d5dd0.tar.bz2 libgats-757042bd5748389d3b984bbff72c2b2e3d9d5dd0.tar.xz libgats-757042bd5748389d3b984bbff72c2b2e3d9d5dd0.zip |
You can read and write integers now. Other types should be pretty easy from here.
Diffstat (limited to 'java/com/xagasoft/gats/GatsOutputStream.java')
-rw-r--r-- | java/com/xagasoft/gats/GatsOutputStream.java | 27 |
1 files changed, 26 insertions, 1 deletions
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 @@ | |||
1 | package com.xagasoft.gats; | 1 | package com.xagasoft.gats; |
2 | 2 | ||
3 | import java.io.InputStream; | ||
4 | import java.io.OutputStream; | 3 | import java.io.OutputStream; |
4 | import java.io.ByteArrayOutputStream; | ||
5 | import java.io.DataOutputStream; | ||
5 | 6 | ||
6 | public class GatsOutputStream | 7 | public 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 | ||