📄 datainputstream.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:34:39 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class DataInputStream</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_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/DataInputStream.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"> <A HREF="../../java/io/CharArrayWriter.html"><B>PREV CLASS</B></A> <A HREF="../../java/io/DataOutputStream.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="DataInputStream.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#fields_inherited_from_class_java.io.FilterInputStream">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.io</FONT><BR>Class DataInputStream</H2><PRE><A HREF="../../java/lang/Object.html">java.lang.Object</A> | +--<A HREF="../../java/io/InputStream.html">java.io.InputStream</A> | +--<A HREF="../../java/io/FilterInputStream.html">java.io.FilterInputStream</A> | +--<B>java.io.DataInputStream</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../java/io/DataInput.html">DataInput</A></DD></DL><HR><DL><DT>public class <B>DataInputStream</B><DT>extends <A HREF="../../java/io/FilterInputStream.html">FilterInputStream</A><DT>implements <A HREF="../../java/io/DataInput.html">DataInput</A></DL><P>A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream. <p> Data input streams and data output streams represent Unicode strings in a format that is a slight modification of UTF-8. (For more information, see X/Open Company Ltd., "File System Safe UCS Transformation Format (FSS_UTF)", X/Open Preliminary Specification, Document Number: P316. This information also appears in ISO/IEC 10646, Annex P.) <p> All characters in the range <code>'\u0001'</code> to <code>'\u007F'</code> are represented by a single byte: <center><table border="3"> <tr><td><i>0</i></td> <td>bits 0-7</td></tr> </table></center> <p> The null character <code>'\u0000'</code> and characters in the range <code>'\u0080'</code> to <code>'\u07FF'</code> are represented by a pair of bytes: <center><table border="3"> <tr><td>1</td> <td>1</td> <td>0</td> <td>bits 6-10</td></tr> <tr><td>1</td> <td>0</td> <td colspan=2>bits 0-5</td></tr> </table></center><br> Characters in the range <code>'\u0800'</code> to <code>'\uFFFF'</code> are represented by three bytes: <center><table border="3"> <tr><td>1</td> <td>1</td> <td>1</td> <td>0</td> <td>bits 12-15</td</tr> <tr><td>1</td> <td>0</td> <td colspan=3>bits 6-11</td></tr> <tr><td>1</td> <td>0</td> <td colspan=3>bits 0-5</td></tr> </table></center> <p> The two differences between this format and the "standard" UTF-8 format are the following: <ul> <li>The null byte <code>'\u0000'</code> is encoded in 2-byte format rather than 1-byte, so that the encoded strings never have embedded nulls. <li>Only the 1-byte, 2-byte, and 3-byte formats are used. </ul><P><DL><DT><B>Since: </B><DD>JDK1.0</DD><DT><B>See Also: </B><DD><A HREF="../../java/io/DataOutputStream.html"><CODE>DataOutputStream</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="fields_inherited_from_class_java.io.FilterInputStream"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Fields inherited from class java.io.<A HREF="../../java/io/FilterInputStream.html">FilterInputStream</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/io/FilterInputStream.html#in">in</A></CODE></TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#DataInputStream(java.io.InputStream)">DataInputStream</A></B>(<A HREF="../../java/io/InputStream.html">InputStream</A> in)</CODE><BR> Creates a <code>FilterInputStream</code> and saves its argument, the input stream <code>in</code>, for later use.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#read(byte[])">read</A></B>(byte[] b)</CODE><BR> See the general contract of the <code>read</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#read(byte[], int, int)">read</A></B>(byte[] b, int off, int len)</CODE><BR> See the general contract of the <code>read</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readBoolean()">readBoolean</A></B>()</CODE><BR> See the general contract of the <code>readBoolean</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readByte()">readByte</A></B>()</CODE><BR> See the general contract of the <code>readByte</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> char</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readChar()">readChar</A></B>()</CODE><BR> See the general contract of the <code>readChar</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> double</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readDouble()">readDouble</A></B>()</CODE><BR> See the general contract of the <code>readDouble</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> float</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readFloat()">readFloat</A></B>()</CODE><BR> See the general contract of the <code>readFloat</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readFully(byte[])">readFully</A></B>(byte[] b)</CODE><BR> See the general contract of the <code>readFully</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readFully(byte[], int, int)">readFully</A></B>(byte[] b, int off, int len)</CODE><BR> See the general contract of the <code>readFully</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readInt()">readInt</A></B>()</CODE><BR> See the general contract of the <code>readInt</code> method of <code>DataInput</code>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readLine()">readLine</A></B>()</CODE><BR> <B>Deprecated.</B> <I>This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the <code>BufferedReader.readLine()</code> method. Programs that use the <code>DataInputStream</code> class to read lines can be converted to use the <code>BufferedReader</code> class by replacing code of the form: <blockquote><pre> DataInputStream d = new DataInputStream(in); </pre></blockquote> with: <blockquote><pre> BufferedReader d = new BufferedReader(new InputStreamReader(in)); </pre></blockquote></I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> long</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataInputStream.html#readLong()">readLong</A></B>()</CODE><BR> See the general contract of the <code>readLong</code>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -