📄 dataoutput.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:35 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface DataOutput</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/DataOutput.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/DataInput.html"><B>PREV CLASS</B></A> <A HREF="../../java/io/Externalizable.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="DataOutput.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><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.io</FONT><BR>Interface DataOutput</H2><DL><DT><B>All Known Subinterfaces:</B> <DD><A HREF="../../java/io/ObjectOutput.html">ObjectOutput</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../java/io/DataOutputStream.html">DataOutputStream</A>, <A HREF="../../java/io/RandomAccessFile.html">RandomAccessFile</A></DD></DL><HR><DL><DT>public interface <B>DataOutput</B></DL><P>The <code>DataOutput</code> interface provides for converting data from any of the Java primitive types to a series of bytes and writing these bytes to a binary stream. There is also a facility for converting a <code>String</code> into Java modified UTF-8 format and writing the resulting series of bytes. <p> For all the methods in this interface that write bytes, it is generally true that if a byte cannot be written for any reason, an <code>IOException</code> is thrown.<P><DL><DT><B>Since: </B><DD>JDK1.0</DD><DT><B>See Also: </B><DD><A HREF="../../java/io/DataInput.html"><CODE>DataInput</CODE></A>, <A HREF="../../java/io/DataOutputStream.html"><CODE>DataOutputStream</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== 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> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/DataOutput.html#write(byte[])">write</A></B>(byte[] b)</CODE><BR> Writes to the output stream all the bytes in array <code>b</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/DataOutput.html#write(byte[], int, int)">write</A></B>(byte[] b, int off, int len)</CODE><BR> Writes <code>len</code> bytes from array <code>b</code>, in order, to the output stream.</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/DataOutput.html#write(int)">write</A></B>(int b)</CODE><BR> Writes to the output stream the eight low-order bits of the argument <code>b</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/DataOutput.html#writeBoolean(boolean)">writeBoolean</A></B>(boolean v)</CODE><BR> Writes a <code>boolean</code> value to this output stream.</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/DataOutput.html#writeByte(int)">writeByte</A></B>(int v)</CODE><BR> Writes to the output stream the eight low- order bits of the argument <code>v</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/DataOutput.html#writeBytes(java.lang.String)">writeBytes</A></B>(<A HREF="../../java/lang/String.html">String</A> s)</CODE><BR> Writes a string to the output stream.</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/DataOutput.html#writeChar(int)">writeChar</A></B>(int v)</CODE><BR> Writes a <code>char</code> value, wich is comprised of two bytes, to the output stream.</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/DataOutput.html#writeChars(java.lang.String)">writeChars</A></B>(<A HREF="../../java/lang/String.html">String</A> s)</CODE><BR> Writes every character in the string <code>s</code>, to the output stream, in order, two bytes per character.</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/DataOutput.html#writeDouble(double)">writeDouble</A></B>(double v)</CODE><BR> Writes a <code>double</code> value, which is comprised of eight bytes, to the output stream.</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/DataOutput.html#writeFloat(float)">writeFloat</A></B>(float v)</CODE><BR> Writes a <code>float</code> value, which is comprised of four bytes, to the output stream.</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/DataOutput.html#writeInt(int)">writeInt</A></B>(int v)</CODE><BR> Writes an <code>int</code> value, which is comprised of four bytes, to the output stream.</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/DataOutput.html#writeLong(long)">writeLong</A></B>(long v)</CODE><BR> Writes an <code>long</code> value, which is comprised of four bytes, to the output stream.</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/DataOutput.html#writeShort(int)">writeShort</A></B>(int v)</CODE><BR> Writes two bytes to the output stream to represent the value of the argument.</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/DataOutput.html#writeUTF(java.lang.String)">writeUTF</A></B>(<A HREF="../../java/lang/String.html">String</A> str)</CODE><BR> Writes two bytes of length information to the output stream, followed by the Java modified UTF representation of every character in the string <code>s</code>.</TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="write(int)"><!-- --></A><H3>write</H3><PRE>public void <B>write</B>(int b) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Writes to the output stream the eight low-order bits of the argument <code>b</code>. The 24 high-order bits of <code>b</code> are ignored.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the byte to be written.<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="write(byte[])"><!-- --></A><H3>write</H3><PRE>public void <B>write</B>(byte[] b) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Writes to the output stream all the bytes in array <code>b</code>. 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 written. Otherwise, the byte <code>b[0]</code> is written first, then <code>b[1]</code>, and so on; the last byte written is <code>b[b.length-1]</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the data.<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="write(byte[], int, int)"><!-- --></A><H3>write</H3><PRE>public void <B>write</B>(byte[] b, int off, int len) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Writes <code>len</code> bytes from array <code>b</code>, in order, to the output stream. 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 written. Otherwise, the byte <code>b[off]</code> is written first, then <code>b[off+1]</code>, and so on; the last byte written is <code>b[off+len-1]</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the data.<DD><CODE>off</CODE> - the start offset in the data.<DD><CODE>len</CODE> - the number of bytes to write.<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="writeBoolean(boolean)"><!-- --></A><H3>writeBoolean</H3><PRE>public void <B>writeBoolean</B>(boolean v) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Writes a <code>boolean</code> value to this output stream. If the argument <code>v</code> is <code>true</code>, the value <code>(byte)1</code> is written; if <code>v</code> is <code>false</code>, the value <code>(byte)0</code> is written. The byte written by this method may be read by the <code>readBoolean</code>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -