📄 datainput.html
字号:
(((a & 0xff) << 24) | ((b & 0xff) << 16) |  ((c & 0xff) << 8) | (d & 0xff)) </code></pre> This method is suitable for reading bytes written by the <code>writeInt</code> method of interface <code>DataOutput</code>.<DD><DL><DT><B>Returns:</B><DD>the <code>int</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="readLong()"><!-- --></A><H3>readLong</H3><PRE>public long <B>readLong</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads eight input bytes and returns a <code>long</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, <code>d</code> be the fourth byte, <code>e</code> be the fifth byte, <code>f</code> be the sixth byte, <code>g</code> be the seventh byte, and <code>h</code> be the eighth byte. The value returned is: <p><pre> <code> (((long)(a & 0xff) << 56) | ((long)(b & 0xff) << 48) | ((long)(c & 0xff) << 40) | ((long)(d & 0xff) << 32) | ((long)(e & 0xff) << 24) | ((long)(f & 0xff) << 16) | ((long)(g & 0xff) << 8) | ((long)(h & 0xff))) </code></pre> <p> This method is suitable for reading bytes written by the <code>writeLong</code> method of interface <code>DataOutput</code>.<DD><DL><DT><B>Returns:</B><DD>the <code>long</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="readFloat()"><!-- --></A><H3>readFloat</H3><PRE>public float <B>readFloat</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads four input bytes and returns a <code>float</code> value. It does this by first constructing an <code>int</code> value in exactly the manner of the <code>readInt</code> method, then converting this <code>int</code> value to a <code>float</code> in exactly the manner of the method <code>Float.intBitsToFloat</code>. This method is suitable for reading bytes written by the <code>writeFloat</code> method of interface <code>DataOutput</code>.<DD><DL><DT><B>Returns:</B><DD>the <code>float</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="readDouble()"><!-- --></A><H3>readDouble</H3><PRE>public double <B>readDouble</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads eight input bytes and returns a <code>double</code> value. It does this by first constructing a <code>long</code> value in exactly the manner of the <code>readlong</code> method, then converting this <code>long</code> value to a <code>double</code> in exactly the manner of the method <code>Double.longBitsToDouble</code>. This method is suitable for reading bytes written by the <code>writeDouble</code> method of interface <code>DataOutput</code>.<DD><DL><DT><B>Returns:</B><DD>the <code>double</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="readLine()"><!-- --></A><H3>readLine</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>readLine</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads the next line of text from the input stream. It reads successive bytes, converting each byte separately into a character, until it encounters a line terminator or end of file; the characters read are then returned as a <code>String</code>. Note that because this method processes bytes, it does not support input of the full Unicode character set. <p> If end of file is encountered before even one byte can be read, then <code>null</code> is returned. Otherwise, each byte that is read is converted to type <code>char</code> by zero-extension. If the character <code>'\n'</code> is encountered, it is discarded and reading ceases. If the character <code>'\r'</code> is encountered, it is discarded and, if the following byte converts  to the character <code>'\n'</code>, then that is discarded also; reading then ceases. If end of file is encountered before either of the characters <code>'\n'</code> and <code>'\r'</code> is encountered, reading ceases. Once reading has ceased, a <code>String</code> is returned that contains all the characters read and not discarded, taken in order. Note that every character in this string will have a value less than <code>\u0100</code>, that is, <code>(char)256</code>.<DD><DL><DT><B>Returns:</B><DD>if this stream reaches the end before reading all the bytes.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</DL></DD></DL><HR><A NAME="readUTF()"><!-- --></A><H3>readUTF</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>readUTF</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads in a string that has been encoded using a modified UTF-8 format. The general contract of <code>readUTF</code> is that it reads a representation of a Unicode character string encoded in Java modified UTF-8 format; this string of characters is then returned as a <code>String</code>. <p> First, two bytes are read and used to construct an unsigned 16-bit integer in exactly the manner of the <code>readUnsignedShort</code> method . This integer value is called the <i>UTF length</i> and specifies the number of additional bytes to be read. These bytes are then converted to characters by considering them in groups. The length of each group is computed from the value of the first byte of the group. The byte following a group, if any, is the first byte of the next group. <p> If the first byte of a group matches the bit pattern <code>0xxxxxxx</code> (where <code>x</code> means "may be <code>0</code> or <code>1</code>"), then the group consists of just that byte. The byte is zero-extended to form a character. <p> If the first byte of a group matches the bit pattern <code>110xxxxx</code>, then the group consists of that byte <code>a</code> and a second byte <code>b</code>. If there is no byte <code>b</code> (because byte <code>a</code> was the last of the bytes to be read), or if byte <code>b</code> does not match the bit pattern <code>10xxxxxx</code>, then a <code>UTFDataFormatException</code> is thrown. Otherwise, the group is converted to the character:<p> <pre><code>(char)(((a& 0x1F) << 6) | (b & 0x3F)) </code></pre> If the first byte of a group matches the bit pattern <code>1110xxxx</code>, then the group consists of that byte <code>a</code> and two more bytes <code>b</code> and <code>c</code>. If there is no byte <code>c</code> (because byte <code>a</code> was one of the last two of the bytes to be read), or either byte <code>b</code> or byte <code>c</code> does not match the bit pattern <code>10xxxxxx</code>, then a <code>UTFDataFormatException</code> is thrown. Otherwise, the group is converted to the character:<p> <pre><code> (char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F)) </code></pre> If the first byte of a group matches the pattern <code>1111xxxx</code> or the pattern <code>10xxxxxx</code>, then a <code>UTFDataFormatException</code> is thrown. <p> If end of file is encountered at any time during this entire process, then an <code>EOFException</code> is thrown. <p> After every group has been converted to a character by this process, the characters are gathered, in the same order in which their corresponding groups were read from the input stream, to form a <code>String</code>, which is returned. <p> The <code>writeUTF</code> method of interface <code>DataOutput</code> may be used to write data that is suitable for reading by this method.<DD><DL><DT><B>Returns:</B><DD>a Unicode string.<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.<DD><CODE><A HREF="../../java/io/UTFDataFormatException.html">UTFDataFormatException</A></CODE> - if the bytes do not represent a valid UTF-8 encoding of a string.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/DataInput.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS <A HREF="../../java/io/DataOutput.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="DataInput.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -