@@ -14,9 +14,6 @@ public class JsonStream extends OutputStream {
1414 public int indentionStep = defaultIndentionStep ;
1515 private int indention = 0 ;
1616 private OutputStream out ;
17- private static final byte [] NULL = "null" .getBytes ();
18- private static final byte [] TRUE = "true" .getBytes ();
19- private static final byte [] FALSE = "false" .getBytes ();
2017 byte buf [];
2118 int count ;
2219
@@ -40,31 +37,54 @@ public final void write(int b) throws IOException {
4037 buf [count ++] = (byte ) b ;
4138 }
4239
43- public final void write (int b1 , int b2 ) throws IOException {
40+ public final void write (byte b1 , byte b2 ) throws IOException {
4441 if (count >= buf .length - 1 ) {
4542 flushBuffer ();
4643 }
47- buf [count ++] = ( byte ) b1 ;
48- buf [count ++] = ( byte ) b2 ;
44+ buf [count ++] = b1 ;
45+ buf [count ++] = b2 ;
4946 }
5047
51- public final void write (int b1 , int b2 , int b3 ) throws IOException {
48+ public final void write (byte b1 , byte b2 , byte b3 ) throws IOException {
5249 if (count >= buf .length - 2 ) {
5350 flushBuffer ();
5451 }
55- buf [count ++] = ( byte ) b1 ;
56- buf [count ++] = ( byte ) b2 ;
57- buf [count ++] = ( byte ) b3 ;
52+ buf [count ++] = b1 ;
53+ buf [count ++] = b2 ;
54+ buf [count ++] = b3 ;
5855 }
5956
60- public final void write (int b1 , int b2 , int b3 , int b4 ) throws IOException {
57+ public final void write (byte b1 , byte b2 , byte b3 , byte b4 ) throws IOException {
6158 if (count >= buf .length - 3 ) {
6259 flushBuffer ();
6360 }
64- buf [count ++] = (byte ) b1 ;
65- buf [count ++] = (byte ) b2 ;
66- buf [count ++] = (byte ) b3 ;
67- buf [count ++] = (byte ) b4 ;
61+ buf [count ++] = b1 ;
62+ buf [count ++] = b2 ;
63+ buf [count ++] = b3 ;
64+ buf [count ++] = b4 ;
65+ }
66+
67+ public final void write (byte b1 , byte b2 , byte b3 , byte b4 , byte b5 ) throws IOException {
68+ if (count >= buf .length - 4 ) {
69+ flushBuffer ();
70+ }
71+ buf [count ++] = b1 ;
72+ buf [count ++] = b2 ;
73+ buf [count ++] = b3 ;
74+ buf [count ++] = b4 ;
75+ buf [count ++] = b5 ;
76+ }
77+
78+ public final void write (byte b1 , byte b2 , byte b3 , byte b4 , byte b5 , byte b6 ) throws IOException {
79+ if (count >= buf .length - 5 ) {
80+ flushBuffer ();
81+ }
82+ buf [count ++] = b1 ;
83+ buf [count ++] = b2 ;
84+ buf [count ++] = b3 ;
85+ buf [count ++] = b4 ;
86+ buf [count ++] = b5 ;
87+ buf [count ++] = b6 ;
6888 }
6989
7090 public final void write (byte b [], int off , int len ) throws IOException {
@@ -117,7 +137,7 @@ public final void writeRaw(String val) throws IOException {
117137
118138 public final void writeRaw (String val , int remaining ) throws IOException {
119139 int i = 0 ;
120- for (;; ) {
140+ for (; ; ) {
121141 int available = buf .length - count ;
122142 if (available < remaining ) {
123143 remaining -= available ;
@@ -156,11 +176,11 @@ public final void writeVal(boolean val) throws IOException {
156176 }
157177
158178 public final void writeTrue () throws IOException {
159- write (TRUE );
179+ write (( byte ) 't' , ( byte ) 'r' , ( byte ) 'u' , ( byte ) 'e' );
160180 }
161181
162182 public final void writeFalse () throws IOException {
163- write (FALSE );
183+ write (( byte ) 'f' , ( byte ) 'a' , ( byte ) 'l' , ( byte ) 's' , ( byte ) 'e' );
164184 }
165185
166186 public final void writeVal (Short val ) throws IOException {
@@ -230,17 +250,15 @@ public final void writeVal(Any val) throws IOException {
230250 }
231251
232252 public final void writeNull () throws IOException {
233- write (NULL , 0 , NULL . length );
253+ write (( byte ) 'n' , ( byte ) 'u' , ( byte ) 'l' , ( byte ) 'l' );
234254 }
235255
236256 public final void writeEmptyObject () throws IOException {
237- write ('{' );
238- write ('}' );
257+ write ((byte ) '{' , (byte ) '}' );
239258 }
240259
241260 public final void writeEmptyArray () throws IOException {
242- write ('[' );
243- write (']' );
261+ write ((byte ) '[' , (byte ) ']' );
244262 }
245263
246264 public final void writeArrayStart () throws IOException {
0 commit comments