84 * @exception IOException if an I/O error occurs.
85 * @see java.io.FilterOutputStream#out
86 */
87 public synchronized void write(int b) throws IOException {
88 out.write(b);
89 incCount(1);
90 }
91
92 /**
93 * Writes <code>len</code> bytes from the specified byte array
94 * starting at offset <code>off</code> to the underlying output stream.
95 * If no exception is thrown, the counter <code>written</code> is
96 * incremented by <code>len</code>.
97 *
98 * @param b the data.
99 * @param off the start offset in the data.
100 * @param len the number of bytes to write.
101 * @exception IOException if an I/O error occurs.
102 * @see java.io.FilterOutputStream#out
103 */
104 public synchronized void write(byte b[], int off, int len)
105 throws IOException
106 {
107 out.write(b, off, len);
108 incCount(len);
109 }
110
111 /**
112 * Flushes this data output stream. This forces any buffered output
113 * bytes to be written out to the stream.
114 * <p>
115 * The <code>flush</code> method of <code>DataOutputStream</code>
116 * calls the <code>flush</code> method of its underlying output stream.
117 *
118 * @exception IOException if an I/O error occurs.
119 * @see java.io.FilterOutputStream#out
120 * @see java.io.OutputStream#flush()
121 */
122 public void flush() throws IOException {
123 out.flush();
124 }
184 incCount(2);
185 }
186
187 /**
188 * Writes an <code>int</code> to the underlying output stream as four
189 * bytes, high byte first. If no exception is thrown, the counter
190 * <code>written</code> is incremented by <code>4</code>.
191 *
192 * @param v an <code>int</code> to be written.
193 * @exception IOException if an I/O error occurs.
194 * @see java.io.FilterOutputStream#out
195 */
196 public final void writeInt(int v) throws IOException {
197 out.write((v >>> 24) & 0xFF);
198 out.write((v >>> 16) & 0xFF);
199 out.write((v >>> 8) & 0xFF);
200 out.write((v >>> 0) & 0xFF);
201 incCount(4);
202 }
203
204 private byte writeBuffer[] = new byte[8];
205
206 /**
207 * Writes a <code>long</code> to the underlying output stream as eight
208 * bytes, high byte first. In no exception is thrown, the counter
209 * <code>written</code> is incremented by <code>8</code>.
210 *
211 * @param v a <code>long</code> to be written.
212 * @exception IOException if an I/O error occurs.
213 * @see java.io.FilterOutputStream#out
214 */
215 public final void writeLong(long v) throws IOException {
216 writeBuffer[0] = (byte)(v >>> 56);
217 writeBuffer[1] = (byte)(v >>> 48);
218 writeBuffer[2] = (byte)(v >>> 40);
219 writeBuffer[3] = (byte)(v >>> 32);
220 writeBuffer[4] = (byte)(v >>> 24);
221 writeBuffer[5] = (byte)(v >>> 16);
222 writeBuffer[6] = (byte)(v >>> 8);
223 writeBuffer[7] = (byte)(v >>> 0);
224 out.write(writeBuffer, 0, 8);
|
84 * @exception IOException if an I/O error occurs.
85 * @see java.io.FilterOutputStream#out
86 */
87 public synchronized void write(int b) throws IOException {
88 out.write(b);
89 incCount(1);
90 }
91
92 /**
93 * Writes <code>len</code> bytes from the specified byte array
94 * starting at offset <code>off</code> to the underlying output stream.
95 * If no exception is thrown, the counter <code>written</code> is
96 * incremented by <code>len</code>.
97 *
98 * @param b the data.
99 * @param off the start offset in the data.
100 * @param len the number of bytes to write.
101 * @exception IOException if an I/O error occurs.
102 * @see java.io.FilterOutputStream#out
103 */
104 public synchronized void write(byte[] b, int off, int len)
105 throws IOException
106 {
107 out.write(b, off, len);
108 incCount(len);
109 }
110
111 /**
112 * Flushes this data output stream. This forces any buffered output
113 * bytes to be written out to the stream.
114 * <p>
115 * The <code>flush</code> method of <code>DataOutputStream</code>
116 * calls the <code>flush</code> method of its underlying output stream.
117 *
118 * @exception IOException if an I/O error occurs.
119 * @see java.io.FilterOutputStream#out
120 * @see java.io.OutputStream#flush()
121 */
122 public void flush() throws IOException {
123 out.flush();
124 }
184 incCount(2);
185 }
186
187 /**
188 * Writes an <code>int</code> to the underlying output stream as four
189 * bytes, high byte first. If no exception is thrown, the counter
190 * <code>written</code> is incremented by <code>4</code>.
191 *
192 * @param v an <code>int</code> to be written.
193 * @exception IOException if an I/O error occurs.
194 * @see java.io.FilterOutputStream#out
195 */
196 public final void writeInt(int v) throws IOException {
197 out.write((v >>> 24) & 0xFF);
198 out.write((v >>> 16) & 0xFF);
199 out.write((v >>> 8) & 0xFF);
200 out.write((v >>> 0) & 0xFF);
201 incCount(4);
202 }
203
204 private byte[] writeBuffer = new byte[8];
205
206 /**
207 * Writes a <code>long</code> to the underlying output stream as eight
208 * bytes, high byte first. In no exception is thrown, the counter
209 * <code>written</code> is incremented by <code>8</code>.
210 *
211 * @param v a <code>long</code> to be written.
212 * @exception IOException if an I/O error occurs.
213 * @see java.io.FilterOutputStream#out
214 */
215 public final void writeLong(long v) throws IOException {
216 writeBuffer[0] = (byte)(v >>> 56);
217 writeBuffer[1] = (byte)(v >>> 48);
218 writeBuffer[2] = (byte)(v >>> 40);
219 writeBuffer[3] = (byte)(v >>> 32);
220 writeBuffer[4] = (byte)(v >>> 24);
221 writeBuffer[5] = (byte)(v >>> 16);
222 writeBuffer[6] = (byte)(v >>> 8);
223 writeBuffer[7] = (byte)(v >>> 0);
224 out.write(writeBuffer, 0, 8);
|