📄 datainput.html
字号:
<B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="readFully(byte[])"><!-- --></A><H3>readFully</H3><PRE>public void <B>readFully</B>(byte[] b) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads some bytes from an input stream and stores them into the buffer array <code>b</code>. The number of bytes read is equal to the length of <code>b</code>. <p> This method blocks until one of the following conditions occurs:<p> <ul> <li><code>b.length</code> bytes of input data are available, in which case a normal return is made. <li>End of file is detected, in which case an <code>EOFException</code> is thrown. <li>An I/O error occurs, in which case an <code>IOException</code> other than <code>EOFException</code> is thrown. </ul> <p> If <code>b</code> is <code>null</code>, a <code>NullPointerException</code> is thrown. If <code>b.length</code> is zero, then no bytes are read. Otherwise, the first byte read is stored into element <code>b[0]</code>, the next one into <code>b[1]</code>, and so on. If an exception is thrown from this method, then it may be that some but not all bytes of <code>b</code> have been updated with data from the input stream.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the buffer into which the data is read.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/EOFException.html">EOFException</A></CODE> - if this stream reaches the end before reading all the bytes.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="readFully(byte[], int, int)"><!-- --></A><H3>readFully</H3><PRE>public void <B>readFully</B>(byte[] b, int off, int len) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads <code>len</code> bytes from an input stream. <p> This method blocks until one of the following conditions occurs:<p> <ul> <li><code>len</code> bytes of input data are available, in which case a normal return is made. <li>End of file is detected, in which case an <code>EOFException</code> is thrown. <li>An I/O error occurs, in which case an <code>IOException</code> other than <code>EOFException</code> is thrown. </ul> <p> If <code>b</code> is <code>null</code>, a <code>NullPointerException</code> is thrown. If <code>off</code> is negative, or <code>len</code> is negative, or <code>off+len</code> is greater than the length of the array <code>b</code>, then an <code>IndexOutOfBoundsException</code> is thrown. If <code>len</code> is zero, then no bytes are read. Otherwise, the first byte read is stored into element <code>b[off]</code>, the next one into <code>b[off+1]</code>, and so on. The number of bytes read is, at most, equal to <code>len</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the buffer into which the data is read.<DD><CODE>off</CODE> - an int specifying the offset into the data.<DD><CODE>len</CODE> - an int specifying the number of bytes to read.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/EOFException.html">EOFException</A></CODE> - if this stream reaches the end before reading all the bytes.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="skipBytes(int)"><!-- --></A><H3>skipBytes</H3><PRE>public int <B>skipBytes</B>(int n) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Makes an attempt to skip over <code>n</code> bytes of data from the input stream, discarding the skipped bytes. However, it may skip over some smaller number of bytes, possibly zero. This may result from any of a number of conditions; reaching end of file before <code>n</code> bytes have been skipped is only one possibility. This method never throws an <code>EOFException</code>. The actual number of bytes skipped is returned.<DD><DL><DT><B>Parameters:</B><DD><CODE>n</CODE> - the number of bytes to be skipped.<DT><B>Returns:</B><DD>the number of bytes skipped, which is always <code>n</code>.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/EOFException.html">EOFException</A></CODE> - if this stream reaches the end before skipping all the bytes.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="readBoolean()"><!-- --></A><H3>readBoolean</H3><PRE>public boolean <B>readBoolean</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads one input byte and returns <code>true</code> if that byte is nonzero, <code>false</code> if that byte is zero. This method is suitable for reading the byte written by the <code>writeBoolean</code> method of interface <code>DataOutput</code>.<DD><DL><DT><B>Returns:</B><DD>the <code>boolean</code> value read.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/EOFException.html">EOFException</A></CODE> - if this stream reaches the end before reading all the bytes.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="readByte()"><!-- --></A><H3>readByte</H3><PRE>public byte <B>readByte</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads and returns one input byte. The byte is treated as a signed value in the range <code>-128</code> through <code>127</code>, inclusive. This method is suitable for reading the byte written by the <code>writeByte</code> method of interface <code>DataOutput</code>.<DD><DL><DT><B>Returns:</B><DD>the 8-bit value read.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/EOFException.html">EOFException</A></CODE> - if this stream reaches the end before reading all the bytes.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="readUnsignedByte()"><!-- --></A><H3>readUnsignedByte</H3><PRE>public int <B>readUnsignedByte</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads one input byte, zero-extends it to type <code>int</code>, and returns the result, which is therefore in the range <code>0</code> through <code>255</code>. This method is suitable for reading the byte written by the <code>writeByte</code> method of interface <code>DataOutput</code> if the argument to <code>writeByte</code> was intended to be a value in the range <code>0</code> through <code>255</code>.<DD><DL><DT><B>Returns:</B><DD>the unsigned 8-bit value read.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/EOFException.html">EOFException</A></CODE> - if this stream reaches the end before reading all the bytes.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="readShort()"><!-- --></A><H3>readShort</H3><PRE>public short <B>readShort</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads two input bytes and returns a <code>short</code> value. Let <code>a</code> be the first byte read and <code>b</code> be the second byte. The value returned is: <p><pre><code>(short)((a << 8) * | (b & 0xff)) </code></pre> This method is suitable for reading the bytes written by the <code>writeShort</code> method of interface <code>DataOutput</code>.<DD><DL><DT><B>Returns:</B><DD>the 16-bit value read.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/EOFException.html">EOFException</A></CODE> - if this stream reaches the end before reading all the bytes.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="readUnsignedShort()"><!-- --></A><H3>readUnsignedShort</H3><PRE>public int <B>readUnsignedShort</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads two input bytes and returns an <code>int</code> value in the range <code>0</code> through <code>65535</code>. Let <code>a</code> be the first byte read and <code>b</code> be the second byte. The value returned is: <p><pre><code>(((a & 0xff) << 8) | (b & 0xff)) </code></pre> This method is suitable for reading the bytes written by the <code>writeShort</code> method of interface <code>DataOutput</code> if the argument to <code>writeShort</code> was intended to be a value in the range <code>0</code> through <code>65535</code>.<DD><DL><DT><B>Returns:</B><DD>the unsigned 16-bit value read.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/EOFException.html">EOFException</A></CODE> - if this stream reaches the end before reading all the bytes.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="readChar()"><!-- --></A><H3>readChar</H3><PRE>public char <B>readChar</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads an input <code>char</code> and returns the <code>char</code> value. A Unicode <code>char</code> is made up of two bytes. Let <code>a</code> be the first byte read and <code>b</code> be the second byte. The value returned is: <p><pre><code>(char)((a << 8) | (b & 0xff)) </code></pre> This method is suitable for reading bytes written by the <code>writeChar</code> method of interface <code>DataOutput</code>.<DD><DL><DT><B>Returns:</B><DD>the Unicode <code>char</code> read.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/EOFException.html">EOFException</A></CODE> - if this stream reaches the end before reading all the bytes.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="readInt()"><!-- --></A><H3>readInt</H3><PRE>public int <B>readInt</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads four input bytes and returns an <code>int</code> value. Let <code>a</code> be the first byte read, <code>b</code> be the second byte, <code>c</code> be the third byte, and <code>d</code> be the fourth byte. The value returned is: <p><pre> <code>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -