diff options
Diffstat (limited to '')
-rw-r--r-- | java/com/xagasoft/gats/GatsInputStream.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/java/com/xagasoft/gats/GatsInputStream.java b/java/com/xagasoft/gats/GatsInputStream.java index e787d56..e1c4781 100644 --- a/java/com/xagasoft/gats/GatsInputStream.java +++ b/java/com/xagasoft/gats/GatsInputStream.java | |||
@@ -2,6 +2,7 @@ package com.xagasoft.gats; | |||
2 | 2 | ||
3 | import java.io.InputStream; | 3 | import java.io.InputStream; |
4 | import java.io.ByteArrayOutputStream; | 4 | import java.io.ByteArrayOutputStream; |
5 | import java.io.ByteArrayInputStream; | ||
5 | import java.io.DataInputStream; | 6 | import java.io.DataInputStream; |
6 | 7 | ||
7 | public class GatsInputStream | 8 | public class GatsInputStream |
@@ -16,7 +17,7 @@ public class GatsInputStream | |||
16 | this.is = is; | 17 | this.is = is; |
17 | } | 18 | } |
18 | 19 | ||
19 | public GatsObject readObject() | 20 | public GatsObject readObject() throws java.io.IOException |
20 | { | 21 | { |
21 | do | 22 | do |
22 | { | 23 | { |
@@ -24,7 +25,7 @@ public class GatsInputStream | |||
24 | { | 25 | { |
25 | byte aBuf[] = new byte[5-baos.size()]; | 26 | byte aBuf[] = new byte[5-baos.size()]; |
26 | int iRead = is.read( aBuf ); | 27 | int iRead = is.read( aBuf ); |
27 | baos.write( ret, iRead ); | 28 | baos.write( aBuf, 0, iRead ); |
28 | 29 | ||
29 | if( baos.size() < 5 ) | 30 | if( baos.size() < 5 ) |
30 | return null; | 31 | return null; |
@@ -36,7 +37,7 @@ public class GatsInputStream | |||
36 | ByteArrayInputStream bais = new ByteArrayInputStream( | 37 | ByteArrayInputStream bais = new ByteArrayInputStream( |
37 | baos.toByteArray() | 38 | baos.toByteArray() |
38 | ); | 39 | ); |
39 | DataInputStream dis( bais ); | 40 | DataInputStream dis = new DataInputStream( bais ); |
40 | iVer = dis.readUnsignedByte(); | 41 | iVer = dis.readUnsignedByte(); |
41 | iSize = dis.readInt(); | 42 | iSize = dis.readInt(); |
42 | } | 43 | } |
@@ -49,7 +50,7 @@ public class GatsInputStream | |||
49 | iGoal = 1500; | 50 | iGoal = 1500; |
50 | 51 | ||
51 | int iRead = is.read( aBuf ); | 52 | int iRead = is.read( aBuf ); |
52 | baos.write( abuf, 0, iRead ); | 53 | baos.write( aBuf, 0, iRead ); |
53 | 54 | ||
54 | if( iRead < iGoal ) | 55 | if( iRead < iGoal ) |
55 | return null; | 56 | return null; |
@@ -63,14 +64,13 @@ public class GatsInputStream | |||
63 | ); | 64 | ); |
64 | bais.skip( 5 ); | 65 | bais.skip( 5 ); |
65 | 66 | ||
66 | GatsObject goRet = GatsObject::read( bais ); | 67 | GatsObject goRet = GatsObject.read( bais ); |
67 | iVer = 0; | 68 | iVer = 0; |
68 | 69 | ||
69 | return goRet; | 70 | return goRet; |
70 | } | 71 | } |
71 | 72 | ||
72 | 73 | private boolean skipReadNulls() | |
73 | private bool skipReadNulls() | ||
74 | { | 74 | { |
75 | if( baos.size() == 0 ) | 75 | if( baos.size() == 0 ) |
76 | return false; | 76 | return false; |
@@ -79,17 +79,17 @@ public class GatsInputStream | |||
79 | if( aBuf[0] != 0 ) | 79 | if( aBuf[0] != 0 ) |
80 | return true; | 80 | return true; |
81 | 81 | ||
82 | for( int j = 1; j < aBuf.size; j++ ) | 82 | for( int j = 1; j < aBuf.length; j++ ) |
83 | { | 83 | { |
84 | if( aBuf[j] != 0 ) | 84 | if( aBuf[j] != 0 ) |
85 | { | 85 | { |
86 | baos.clear(); | 86 | baos.reset(); |
87 | baos.write( aBuf, j, aBuf.size-j ); | 87 | baos.write( aBuf, j, aBuf.length-j ); |
88 | return true; | 88 | return true; |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | baos.clear(); | 92 | baos.reset(); |
93 | return true; | 93 | return true; |
94 | } | 94 | } |
95 | }; | 95 | }; |