📄 pushbackinputstream.html
字号:
<HR><A NAME="pos"><!-- --></A><H3>pos</H3><PRE>protected int <B>pos</B></PRE><DL><DD>The position within the pushback buffer from which the next byte will be read. When the buffer is empty, <code>pos</code> is equal to <code>buf.length</code>; when the buffer is full, <code>pos</code> is equal to zero.<DD><DL><DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></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="PushbackInputStream(java.io.InputStream, int)"><!-- --></A><H3>PushbackInputStream</H3><PRE>public <B>PushbackInputStream</B>(<A HREF="../../java/io/InputStream.html">InputStream</A> in, int size)</PRE><DL><DD>Creates a <code>PushbackInputStream</code> with a pushback buffer of the specified <code>size</code>, and saves its argument, the input stream <code>in</code>, for later use. Initially, there is no pushed-back byte (the field <code>pushBack</code> is initialized to <code>-1</code>).<DD><DL><DT><B>Parameters:</B><DD><CODE>in</CODE> - the input stream from which bytes will be read.<DD><CODE>size</CODE> - the size of the pushback buffer.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if size is <= 0<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="PushbackInputStream(java.io.InputStream)"><!-- --></A><H3>PushbackInputStream</H3><PRE>public <B>PushbackInputStream</B>(<A HREF="../../java/io/InputStream.html">InputStream</A> in)</PRE><DL><DD>Creates a <code>PushbackInputStream</code> and saves its argument, the input stream <code>in</code>, for later use. Initially, there is no pushed-back byte (the field <code>pushBack</code> is initialized to <code>-1</code>).<DD><DL><DT><B>Parameters:</B><DD><CODE>in</CODE> - the input stream from which bytes will be read.</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>() throws <A HREF="../../java/io/IOException.html">IOException</A></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. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown. <p> This method returns the most recently pushed-back byte, if there is one, and otherwise calls the <code>read</code> method of its underlying input stream and returns whatever value that method returns.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/FilterInputStream.html#read()">read</A></CODE> in class <CODE><A HREF="../../java/io/FilterInputStream.html">FilterInputStream</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.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.<DT><B>See Also: </B><DD><A HREF="../../java/io/InputStream.html#read()"><CODE>InputStream.read()</CODE></A></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) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Reads up to <code>len</code> bytes of data from this input stream into an array of bytes. This method first reads any pushed-back bytes; after that, if fewer than than <code>len</code> bytes have been read then it reads from the underlying input stream. This method blocks until at least 1 byte of input is available.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/FilterInputStream.html#read(byte[], int, int)">read</A></CODE> in class <CODE><A HREF="../../java/io/FilterInputStream.html">FilterInputStream</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.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.<DT><B>See Also: </B><DD><A HREF="../../java/io/InputStream.html#read(byte[], int, int)"><CODE>InputStream.read(byte[], int, int)</CODE></A></DL></DD></DL><HR><A NAME="unread(int)"><!-- --></A><H3>unread</H3><PRE>public void <B>unread</B>(int b) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Pushes back a byte by copying it to the front of the pushback buffer. After this method returns, the next byte to be read will have the value <code>(byte)b</code>.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the <code>int</code> value whose low-order byte is to be pushed back.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - If there is not enough room in the pushback buffer for the byte.</DL></DD></DL><HR><A NAME="unread(byte[], int, int)"><!-- --></A><H3>unread</H3><PRE>public void <B>unread</B>(byte[] b, int off, int len) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Pushes back a portion of an array of bytes by copying it to the front of the pushback buffer. After this method returns, the next byte to be read will have the value <code>b[off]</code>, the byte after that will have the value <code>b[off+1]</code>, and so forth.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the byte array to push back.<DD><CODE>off</CODE> - the start offset of the data.<DD><CODE>len</CODE> - the number of bytes to push back.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - If there is not enough room in the pushback buffer for the specified number of bytes.<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="unread(byte[])"><!-- --></A><H3>unread</H3><PRE>public void <B>unread</B>(byte[] b) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Pushes back an array of bytes by copying it to the front of the pushback buffer. After this method returns, the next byte to be read will have the value <code>b[0]</code>, the byte after that will have the value <code>b[1]</code>, and so forth.<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the byte array to push back<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - If there is not enough room in the pushback buffer for the specified number of bytes.<DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="available()"><!-- --></A><H3>available</H3><PRE>public int <B>available</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Returns the number of bytes that can be read from this input stream without blocking. This method calls the <code>available</code> method of the underlying input stream; it returns that value plus the number of bytes that have been pushed back.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/FilterInputStream.html#available()">available</A></CODE> in class <CODE><A HREF="../../java/io/FilterInputStream.html">FilterInputStream</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.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.<DT><B>See Also: </B><DD><A HREF="../../java/io/FilterInputStream.html#in"><CODE>FilterInputStream.in</CODE></A>, <A HREF="../../java/io/InputStream.html#available()"><CODE>InputStream.available()</CODE></A></DL></DD></DL><HR><A NAME="skip(long)"><!-- --></A><H3>skip</H3><PRE>public long <B>skip</B>(long n) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Skips over and discards <code>n</code> bytes of data from this input stream. The <code>skip</code> method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly zero. If <code>n</code> is negative, no bytes are skipped. <p> The <code>skip</code> method of <code>PushbackInputStream</code> first skips over the bytes in the pushback buffer, if any. It then calls the <code>skip</code> method of the underlying input stream if more bytes need to be skipped. The actual number of bytes skipped is returned.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/FilterInputStream.html#skip(long)">skip</A></CODE> in class <CODE><A HREF="../../java/io/FilterInputStream.html">FilterInputStream</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.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.<DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../java/io/FilterInputStream.html#in"><CODE>FilterInputStream.in</CODE></A>, <A HREF="../../java/io/InputStream.html#skip(long)"><CODE>InputStream.skip(long n)</CODE></A></DL></DD></DL><HR><A NAME="markSupported()"><!-- --></A><H3>markSupported</H3><PRE>public boolean <B>markSupported</B>()</PRE><DL><DD>Tests if this input stream supports the <code>mark</code> and <code>reset</code> methods, which it does not.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/FilterInputStream.html#markSupported()">markSupported</A></CODE> in class <CODE><A HREF="../../java/io/FilterInputStream.html">FilterInputStream</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>false</code>, since this class does not support the <code>mark</code> and <code>reset</code> methods.<DT><B>See Also: </B><DD><A HREF="../../java/io/InputStream.html#mark(int)"><CODE>InputStream.mark(int)</CODE></A>, <A HREF="../../java/io/InputStream.html#reset()"><CODE>InputStream.reset()</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.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/io/FilterInputStream.html#close()">close</A></CODE> in class <CODE><A HREF="../../java/io/FilterInputStream.html">FilterInputStream</A></CODE></DL></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/PushbackInputStream.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/PrintWriter.html"><B>PREV CLASS</B></A> <A HREF="../../java/io/PushbackReader.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="PushbackInputStream.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 + -