📄 bytearrayinputstream.html
字号:
ByteArrayInputStream objects are marked at position zero by default when constructed. They may be marked at another position within the buffer by the <code>mark()</code> method. The current buffer position is set to this point by the <code>reset()</code> method.<DD><DL><DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="count"><!-- --></A><H3>count</H3><PRE>protected int <B>count</B></PRE><DL><DD>The index one greater than the last valid character in the input stream buffer. This value should always be nonnegative and not larger than the length of <code>buf</code>. It is one greater than the position of the last byte within <code>buf</code> that can ever be read from the input stream buffer.</DL><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="ByteArrayInputStream(byte[])"><!-- --></A><H3>ByteArrayInputStream</H3><PRE>public <B>ByteArrayInputStream</B>(byte[] buf)</PRE><DL><DD>Creates a <code>ByteArrayInputStream</code> so that it uses <code>buf</code> as its buffer array. The buffer array is not copied. The initial value of <code>pos</code> is <code>0</code> and the initial value of <code>count</code> is the length of <code>buf</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>buf</CODE> - the input buffer.</DL></DD></DL><HR><A NAME="ByteArrayInputStream(byte[], int, int)"><!-- --></A><H3>ByteArrayInputStream</H3><PRE>public <B>ByteArrayInputStream</B>(byte[] buf, int offset, int length)</PRE><DL><DD>Creates <code>ByteArrayInputStream</code> that uses <code>buf</code> as its buffer array. The initial value of <code>pos</code> is <code>offset</code> and the initial value of <code>count</code> is <code>offset+len</code>. The buffer array is not copied. <p> Note that if bytes are simply read from the resulting input stream, elements <code>buf[pos]</code> through <code>buf[pos+len-1]</code> will be read; however, if a <code>reset</code> operation is performed, then bytes <code>buf[0]</code> through b<code>uf[pos-1]</code> will then become available for input.<DD><DL><DT><B>Parameters:</B><DD><CODE>buf</CODE> - the input buffer.<DD><CODE>offset</CODE> - the offset in the buffer of the first byte to read.<DD><CODE>length</CODE> - the maximum number of bytes to read from the buffer.</DL></DD></DL><!-- ============ 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="read()"><!-- --></A><H3>read</H3><PRE>public int <B>read</B>()</PRE><DL><DD>Reads the next byte of data from this input stream. The value byte is returned as an <code>int</code> in the range <code>0</code> to <code>255</code>. If no byte is available because the end of the stream has been reached, the value <code>-1</code> is returned. <p> This <code>read</code> method cannot block.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/InputStream.html#read()">read</A></CODE> in class <CODE><A HREF="../../java/io/InputStream.html">InputStream</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the next byte of data, or <code>-1</code> if the end of the stream has been reached.</DL></DD></DL><HR><A NAME="read(byte[], int, int)"><!-- --></A><H3>read</H3><PRE>public int <B>read</B>(byte[] b, int off, int len)</PRE><DL><DD>Reads up to <code>len</code> bytes of data into an array of bytes from this input stream. If <code>pos</code> equals <code>count</code>, then <code>-1</code> is returned to indicate end of file. Otherwise, the number <code>k</code> of bytes read is equal to the smaller of <code>len</code> and <code>count-pos</code>. If <code>k</code> is positive, then bytes <code>buf[pos]</code> through <code>buf[pos+k-1]</code> are copied into <code>b[off]</code> through <code>b[off+k-1]</code> in the manner performed by <code>System.arraycopy</code>. The value <code>k</code> is added into <code>pos</code> and <code>k</code> is returned. <p> This <code>read</code> method cannot block.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/InputStream.html#read(byte[], int, int)">read</A></CODE> in class <CODE><A HREF="../../java/io/InputStream.html">InputStream</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the buffer into which the data is read.<DD><CODE>off</CODE> - the start offset of the data.<DD><CODE>len</CODE> - the maximum number of bytes read.<DT><B>Returns:</B><DD>the total number of bytes read into the buffer, or <code>-1</code> if there is no more data because the end of the stream has been reached.</DL></DD></DL><HR><A NAME="skip(long)"><!-- --></A><H3>skip</H3><PRE>public long <B>skip</B>(long n)</PRE><DL><DD>Skips <code>n</code> bytes of input from this input stream. Fewer bytes might be skipped if the end of the input stream is reached. The actual number <code>k</code> of bytes to be skipped is equal to the smaller of <code>n</code> and <code>count-pos</code>. The value <code>k</code> is added into <code>pos</code> and <code>k</code> is returned.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/InputStream.html#skip(long)">skip</A></CODE> in class <CODE><A HREF="../../java/io/InputStream.html">InputStream</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>n</CODE> - the number of bytes to be skipped.<DT><B>Returns:</B><DD>the actual number of bytes skipped.</DL></DD></DL><HR><A NAME="available()"><!-- --></A><H3>available</H3><PRE>public int <B>available</B>()</PRE><DL><DD>Returns the number of bytes that can be read from this input stream without blocking. The value returned is <code>count - pos</code>, which is the number of bytes remaining to be read from the input buffer.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/InputStream.html#available()">available</A></CODE> in class <CODE><A HREF="../../java/io/InputStream.html">InputStream</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the number of bytes that can be read from the input stream without blocking.</DL></DD></DL><HR><A NAME="markSupported()"><!-- --></A><H3>markSupported</H3><PRE>public boolean <B>markSupported</B>()</PRE><DL><DD>Tests if ByteArrayInputStream supports mark/reset.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/InputStream.html#markSupported()">markSupported</A></CODE> in class <CODE><A HREF="../../java/io/InputStream.html">InputStream</A></CODE></DL></DD><DD><DL><DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="mark(int)"><!-- --></A><H3>mark</H3><PRE>public void <B>mark</B>(int readAheadLimit)</PRE><DL><DD>Set the current marked position in the stream. ByteArrayInputStream objects are marked at position zero by default when constructed. They may be marked at another position within the buffer by this method.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/InputStream.html#mark(int)">mark</A></CODE> in class <CODE><A HREF="../../java/io/InputStream.html">InputStream</A></CODE></DL></DD><DD><DL><DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="reset()"><!-- --></A><H3>reset</H3><PRE>public void <B>reset</B>()</PRE><DL><DD>Resets the buffer to the marked position. The marked position is the beginning unless another position was marked. The value of <code>pos</code> is set to 0.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/InputStream.html#reset()">reset</A></CODE> in class <CODE><A HREF="../../java/io/InputStream.html">InputStream</A></CODE></DL></DD><DD>Following copied from class: <CODE>java.io.InputStream</CODE></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if this stream has not been marked or if the mark has been invalidated.<DT><B>See Also: </B><DD><A HREF="../../java/io/InputStream.html#mark(int)"><CODE>InputStream.mark(int)</CODE></A>, <A HREF="../../java/io/IOException.html"><CODE>IOException</CODE></A></DL></DD></DL><HR><A NAME="close()"><!-- --></A><H3>close</H3><PRE>public void <B>close</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Closes this input stream and releases any system resources associated with the stream. <p><DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/InputStream.html#close()">close</A></CODE> in class <CODE><A HREF="../../java/io/InputStream.html">InputStream</A></CODE></DL></DD><DD>Following copied from class: <CODE>java.io.InputStream</CODE></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.</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/ByteArrayInputStream.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/BufferedWriter.html"><B>PREV CLASS</B></A> <A HREF="../../java/io/ByteArrayOutputStream.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="ByteArrayInputStream.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">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: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <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 + -