129 |
* @exception EOFException If end of file is reached before reading |
* @exception EOFException If end of file is reached before reading |
130 |
* the boolean |
* the boolean |
131 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
132 |
|
* |
133 |
|
* @see DataOutput#writeBoolean |
134 |
*/ |
*/ |
135 |
public final boolean readBoolean() throws IOException |
public final boolean readBoolean() throws IOException |
136 |
{ |
{ |
154 |
* @exception EOFException If end of file is reached before reading the byte |
* @exception EOFException If end of file is reached before reading the byte |
155 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
156 |
* |
* |
157 |
* @see DataOutput |
* @see DataOutput#writeByte |
158 |
*/ |
*/ |
159 |
public final byte readByte() throws IOException |
public final byte readByte() throws IOException |
160 |
{ |
{ |
187 |
* @exception EOFException If end of file is reached before reading the char |
* @exception EOFException If end of file is reached before reading the char |
188 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
189 |
* |
* |
190 |
* @see DataOutput |
* @see DataOutput#writeChar |
191 |
*/ |
*/ |
192 |
public synchronized final char readChar() throws IOException |
public synchronized final char readChar() throws IOException |
193 |
{ |
{ |
213 |
* the double |
* the double |
214 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
215 |
* |
* |
216 |
* @see java.lang.Double |
* @see DataOutput#writeDouble |
217 |
* @see DataOutput |
* @see java.lang.Double#longBitsToDouble |
218 |
*/ |
*/ |
219 |
public final double readDouble() throws IOException |
public final double readDouble() throws IOException |
220 |
{ |
{ |
230 |
* in the class <code>java.lang.Float</code> |
* in the class <code>java.lang.Float</code> |
231 |
* <p> |
* <p> |
232 |
* This method can read a <code>float</code> written by an object |
* This method can read a <code>float</code> written by an object |
233 |
* implementing the * <code>writeFloat()</code> method in the |
* implementing the <code>writeFloat()</code> method in the |
234 |
* <code>DataOutput</code> interface. |
* <code>DataOutput</code> interface. |
235 |
* |
* |
236 |
* @return The <code>float</code> value read |
* @return The <code>float</code> value read |
238 |
* @exception EOFException If end of file is reached before reading the float |
* @exception EOFException If end of file is reached before reading the float |
239 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
240 |
* |
* |
241 |
* @see java.lang.Float |
* @see DataOutput#writeFloat |
242 |
* @see DataOutput */ |
* @see java.lang.Float#intBitsToFloat |
243 |
|
*/ |
244 |
public final float readFloat() throws IOException |
public final float readFloat() throws IOException |
245 |
{ |
{ |
246 |
return Float.intBitsToFloat(readInt()); |
return Float.intBitsToFloat(readInt()); |
250 |
* This method reads raw bytes into the passed array until the array is |
* This method reads raw bytes into the passed array until the array is |
251 |
* full. Note that this method blocks until the data is available and |
* full. Note that this method blocks until the data is available and |
252 |
* throws an exception if there is not enough data left in the stream to |
* throws an exception if there is not enough data left in the stream to |
253 |
* fill the buffer |
* fill the buffer. Note also that zero length buffers are permitted. |
254 |
|
* In this case, the method will return immediately without reading any |
255 |
|
* bytes from the stream. |
256 |
* |
* |
257 |
* @param b The buffer into which to read the data |
* @param buf The buffer into which to read the data |
258 |
* |
* |
259 |
* @exception EOFException If end of file is reached before filling |
* @exception EOFException If end of file is reached before filling the |
260 |
* the buffer |
* buffer |
261 |
* @exception IOException If any other error occurs */ |
* @exception IOException If any other error occurs |
262 |
|
*/ |
263 |
public final void readFully(byte[] b) throws IOException |
public final void readFully(byte[] b) throws IOException |
264 |
{ |
{ |
265 |
readFully(b, 0, b.length); |
readFully(b, 0, b.length); |
266 |
} |
} |
267 |
|
|
268 |
/** |
/** |
269 |
* This method reads raw bytes into the passed array |
* This method reads raw bytes into the passed array <code>buf</code> |
270 |
* <code>buf</code> starting <code>offset</code> bytes into the |
* starting |
271 |
* buffer. The number of bytes read will be exactly |
* <code>offset</code> bytes into the buffer. The number of bytes read |
272 |
* <code>len</code> Note that this method blocks until the data is |
* will be |
273 |
* available and * throws an exception if there is not enough data |
* exactly <code>len</code>. Note that this method blocks until the data is |
274 |
* left in the stream to read <code>len</code> bytes. |
* available and throws an exception if there is not enough data left in |
275 |
|
* the stream to read <code>len</code> bytes. Note also that zero length |
276 |
|
* buffers are permitted. In this case, the method will return immediately |
277 |
|
* without reading any bytes from the stream. |
278 |
* |
* |
279 |
* @param buf The buffer into which to read the data |
* @param buf The buffer into which to read the data |
280 |
* @param offset The offset into the buffer to start storing data |
* @param offset The offset into the buffer to start storing data |
281 |
* @param len The number of bytes to read into the buffer |
* @param len The number of bytes to read into the buffer |
282 |
* |
* |
283 |
* @exception EOFException If end of file is reached before filling |
* @exception EOFException If end of file is reached before filling the |
284 |
* the buffer |
* buffer |
285 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
286 |
*/ |
*/ |
287 |
public final void readFully(byte[] b, int off, int len) throws IOException |
public final void readFully(byte[] b, int off, int len) throws IOException |
298 |
} |
} |
299 |
|
|
300 |
/** |
/** |
301 |
* This method reads a Java <code>int</code> value from an input |
* This method reads a Java <code>int</code> value from an input stream |
302 |
* stream It operates by reading four bytes from the stream and |
* It operates by reading four bytes from the stream and converting them to |
303 |
* converting them to a single Java <code>int</code> The bytes are |
* a single Java <code>int</code>. The bytes are stored most |
304 |
* stored most significant byte first (i.e., "big endian") |
* significant byte first (i.e., "big endian") regardless of the native |
305 |
* regardless of the native host byte ordering. |
* host byte ordering. |
306 |
* <p> |
* <p> |
307 |
* As an example, if <code>byte1</code> through <code>byte4</code> |
* As an example, if <code>byte1</code> through <code>byte4</code> represent |
308 |
* represent the first four bytes read from the stream, they will be |
* the first four bytes read from the stream, they will be |
309 |
* transformed to an <code>int</code> in the following manner: |
* transformed to an <code>int</code> in the following manner: |
310 |
* <p> |
* <p> |
311 |
* <code>(int)(((byte1 & 0xFF) << 24) + ((byte2 & 0xFF) << 16) + |
* <code>(int)(((byte1 & 0xFF) << 24) + ((byte2 & 0xFF) << 16) + |
312 |
* ((byte3 & 0xFF) << 8) + (byte4 & 0xFF)))</code> |
* ((byte3 & 0xFF)<< 8) + (byte4 & 0xFF)))</code> |
313 |
* <p> |
* <p> |
314 |
* The value returned is in the range of 0 to 65535. |
* The value returned is in the range of -2147483648 to 2147483647. |
315 |
* <p> |
* <p> |
316 |
* This method can read an <code>int</code> written by an object |
* This method can read an <code>int</code> written by an object |
317 |
* implementing the <code>writeInt()</code> method in the |
* implementing the <code>writeInt()</code> method in the |
322 |
* @exception EOFException If end of file is reached before reading the int |
* @exception EOFException If end of file is reached before reading the int |
323 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
324 |
* |
* |
325 |
* @see DataOutput |
* @see DataOutput#writeInt |
326 |
*/ |
*/ |
327 |
public synchronized final int readInt() throws IOException |
public synchronized final int readInt() throws IOException |
328 |
{ |
{ |
346 |
* <code>\r\n</code>. These termination charaters are discarded and |
* <code>\r\n</code>. These termination charaters are discarded and |
347 |
* are not returned as part of the string. |
* are not returned as part of the string. |
348 |
* <p> |
* <p> |
|
* This method can read data that was written by an object implementing the |
|
|
* <code>writeLine()</code> method in <code>DataOutput</code>. |
|
349 |
* |
* |
350 |
* @return The line read as a <code>String</code> |
* @return The line read as a <code>String</code> |
351 |
* |
* |
352 |
* @exception IOException If an error occurs |
* @exception IOException If an error occurs |
353 |
* |
* |
|
* @see DataOutput |
|
|
* |
|
354 |
* @deprecated |
* @deprecated |
355 |
*/ |
*/ |
356 |
public final String readLine() throws IOException |
public final String readLine() throws IOException |
441 |
} |
} |
442 |
|
|
443 |
/** |
/** |
444 |
* This method reads a Java long value from an input stream |
* This method reads a Java <code>long</code> value from an input stream |
445 |
* It operates by reading eight bytes from the stream and converting them to |
* It operates by reading eight bytes from the stream and converting them to |
446 |
* a single Java <code>long</code> The bytes are stored most |
* a single Java <code>long</code>. The bytes are stored most |
447 |
* significant byte first (i.e., "big endian") regardless of the native |
* significant byte first (i.e., "big endian") regardless of the native |
448 |
* host byte ordering. |
* host byte ordering. |
449 |
* <p> |
* <p> |
450 |
* As an example, if <code>byte1</code> through <code>byte8</code> |
* As an example, if <code>byte1</code> through <code>byte8</code> represent |
451 |
* represent the first eight bytes read from the stream, they will |
* the first eight bytes read from the stream, they will be |
452 |
* be transformed to an <code>long</code> in the following manner: |
* transformed to an <code>long</code> in the following manner: |
453 |
* <p> |
* <p> |
454 |
* <code>(long)((((long)byte1 & 0xFF) << 56) + (((long)byte2 & 0xFF) << 48) + |
* <code>(long)(((byte1 & 0xFF) << 56) + ((byte2 & 0xFF) << 48) + |
455 |
* (((long)byte3 & 0xFF) << 40) + (((long)byte4 & 0xFF) << 32) + |
* ((byte3 & 0xFF) << 40) + ((byte4 & 0xFF) << 32) + |
456 |
* (((long)byte5 & 0xFF) << 24) + (((long)byte6 & 0xFF) << 16) + |
* ((byte5 & 0xFF) << 24) + ((byte6 & 0xFF) << 16) + |
457 |
* (((long)byte7 & 0xFF) << 8) + ((long)byte9 & 0xFF)))</code> |
* ((byte7 & 0xFF) << 8) + (byte8 & 0xFF))) |
458 |
|
* </code> |
459 |
* <p> |
* <p> |
460 |
* The value returned is in the range of 0 to 65535. |
* The value returned is in the range of -9223372036854775808 to |
461 |
|
* 9223372036854775807. |
462 |
* <p> |
* <p> |
463 |
* This method can read an <code>long</code> written by an object |
* This method can read an <code>long</code> written by an object |
464 |
* implementing the <code>writeLong()</code> method in the |
* implementing the <code>writeLong()</code> method in the |
469 |
* @exception EOFException If end of file is reached before reading the long |
* @exception EOFException If end of file is reached before reading the long |
470 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
471 |
* |
* |
472 |
* @see DataOutput |
* @see DataOutput#writeLong |
473 |
*/ |
*/ |
474 |
public synchronized final long readLong() throws IOException |
public synchronized final long readLong() throws IOException |
475 |
{ |
{ |
496 |
* respectively, they will be transformed to a <code>short</code>. in |
* respectively, they will be transformed to a <code>short</code>. in |
497 |
* the following manner: |
* the following manner: |
498 |
* <p> |
* <p> |
499 |
* <code>(short)(((byte1 & 0xFF) << 8) | (byte2 & 0xFF)</code> |
* <code>(short)(((byte1 & 0xFF) << 8) | (byte2 & 0xFF))</code> |
500 |
* <p> |
* <p> |
501 |
* The value returned is in the range of -32768 to 32767. |
* The value returned is in the range of -32768 to 32767. |
502 |
* <p> |
* <p> |
509 |
* @exception EOFException If end of file is reached before reading the value |
* @exception EOFException If end of file is reached before reading the value |
510 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
511 |
* |
* |
512 |
* @see DataOutput |
* @see DataOutput#writeShort |
513 |
*/ |
*/ |
514 |
public synchronized final short readShort() throws IOException |
public synchronized final short readShort() throws IOException |
515 |
{ |
{ |
523 |
* 255. |
* 255. |
524 |
* <p> |
* <p> |
525 |
* This method can read an unsigned byte written by an object |
* This method can read an unsigned byte written by an object |
526 |
* implementing the <code>writeUnsignedByte()</code> method in the |
* implementing the <code>writeByte()</code> method in the |
527 |
* <code>DataOutput</code> interface. |
* <code>DataOutput</code> interface. |
528 |
* |
* |
529 |
* @return The unsigned bytes value read as a Java <code>int</code>. |
* @return The unsigned bytes value read as a Java <code>int</code>. |
531 |
* @exception EOFException If end of file is reached before reading the value |
* @exception EOFException If end of file is reached before reading the value |
532 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
533 |
* |
* |
534 |
* @see DataOutput |
* @see DataOutput#writeByte |
535 |
*/ |
*/ |
536 |
public final int readUnsignedByte() throws IOException |
public final int readUnsignedByte() throws IOException |
537 |
{ |
{ |
558 |
* The value returned is in the range of 0 to 65535. |
* The value returned is in the range of 0 to 65535. |
559 |
* <p> |
* <p> |
560 |
* This method can read an unsigned short written by an object |
* This method can read an unsigned short written by an object |
561 |
* implementing the <code>writeUnsignedShort()</code> method in the |
* implementing the <code>writeShort()</code> method in the |
562 |
* <code>DataOutput</code> interface. |
* <code>DataOutput</code> interface. |
563 |
* |
* |
564 |
* @return The unsigned short value read as a Java <code>int</code> |
* @return The unsigned short value read as a Java <code>int</code> |
565 |
* |
* |
566 |
* @exception EOFException If end of file is reached before reading the value |
* @exception EOFException If end of file is reached before reading the value |
567 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
568 |
|
* |
569 |
|
* @see DataOutput#writeShort |
570 |
*/ |
*/ |
571 |
public final synchronized int readUnsignedShort() throws IOException |
public final synchronized int readUnsignedShort() throws IOException |
572 |
{ |
{ |
643 |
* @exception UTFDataFormatException If the data is not in UTF-8 format |
* @exception UTFDataFormatException If the data is not in UTF-8 format |
644 |
* @exception IOException If any other error occurs |
* @exception IOException If any other error occurs |
645 |
* |
* |
646 |
* @see DataOutput |
* @see DataOutput#writeUTF |
647 |
*/ |
*/ |
648 |
public final String readUTF() throws IOException |
public final String readUTF() throws IOException |
649 |
{ |
{ |
672 |
* @return The String read from the source |
* @return The String read from the source |
673 |
* |
* |
674 |
* @exception IOException If an error occurs |
* @exception IOException If an error occurs |
675 |
|
* |
676 |
|
* @see DataInput#readUTF |
677 |
*/ |
*/ |
678 |
public final static String readUTF(DataInput in) throws IOException |
public final static String readUTF(DataInput in) throws IOException |
679 |
{ |
{ |
695 |
* This method will not skip any bytes if passed a negative number of bytes |
* This method will not skip any bytes if passed a negative number of bytes |
696 |
* to skip. |
* to skip. |
697 |
* |
* |
698 |
* @param n The requested number of bytes to skip. |
* @param numBytes The requested number of bytes to skip. |
699 |
|
* |
700 |
* @return The requested number of bytes to skip. |
* @return The requested number of bytes to skip. |
701 |
|
* |
702 |
* @exception IOException If an error occurs. |
* @exception IOException If an error occurs. |
703 |
* @specnote The JDK docs claim that this returns the number of bytes |
* @specnote The JDK docs claim that this returns the number of bytes |
704 |
* actually skipped. The JCL claims that this method can throw an |
* actually skipped. The JCL claims that this method can throw an |