当前位置:首页 > Java语言编程规范.
Java语言编程规范for ETS Version: <1.0> Date: <2003/3/13> 中经互联网络有限公司
* Skip characters. *
* @param n The number of characters to skip *
* @return The number of characters actually skipped *
* @exception IOException If an I/O error occurs */
public long skip(long n) throws IOException { if (n < 0L) { throw new IllegalArgumentException(\ } synchronized (lock) { ensureOpen(); long r = n; while (r > 0) { if (nextChar >= nChars) fill(); if (nextChar >= nChars) /* EOF */ break; long d = nChars - nextChar; if (r <= d) { nextChar += r; r = 0; break; } else { r -= d; nextChar = nChars; } } return n - r; } }
/**
* Tell whether this stream is ready to be read. A buffered character * stream is ready if the buffer is not empty, or if the underlying * character stream is ready. *
* @exception IOException If an I/O error occurs */
public boolean ready() throws IOException { synchronized (lock) { ensureOpen(); return (nextChar < nChars) || in.ready(); } Confidential ?中经互联网络有限公司
Page 29 of 31
Java语言编程规范for ETS Version: <1.0> Date: <2003/3/13> 中经互联网络有限公司
/**
* Tell whether this stream supports the mark() operation, which it does. */
public boolean markSupported() { return true; }
/**
* Mark the present position in the stream. Subsequent calls to reset() * will attempt to reposition the stream to this point. *
* @param readAheadLimit Limit on the number of characters that may be * read while still preserving the mark. After * reading this many characters, attempting to
* reset the stream may fail. A limit value larger * than the size of the input buffer will cause a * new buffer to be allocated whose size is no * smaller than limit. Therefore large values * should be used with care. *
* @exception IllegalArgumentException If readAheadLimit is < 0 * @exception IOException If an I/O error occurs */
public void mark(int readAheadLimit) throws IOException { if (readAheadLimit < 0) { throw new IllegalArgumentException(\ } synchronized (lock) { ensureOpen(); this.readAheadLimit = readAheadLimit; markedChar = nextChar; } }
/**
* Reset the stream to the most recent mark. *
* @exception IOException If the stream has never been marked, * or if the mark has been invalidated */
public void reset() throws IOException { synchronized (lock) { ensureOpen(); if (markedChar < 0) throw new IOException((markedChar == INVALIDATED) ? \Confidential ?中经互联网络有限公司
Page 30 of 31
Java语言编程规范for ETS 中经互联网络有限公司
/**
* Close the stream. *
* @exception IOException If an I/O error occurs */
public void close() throws IOException { synchronized (lock) { if (in == null) return; in.close(); in = null; cb = null; } } }
Confidential ?中经互联网络有限公司
Version: <1.0> Date: <2003/3/13> Page 31 of 31
共分享92篇相关文档