java.io.BufferedReader.ensureOpen()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(296)

本文整理了Java中java.io.BufferedReader.ensureOpen()方法的一些代码示例,展示了BufferedReader.ensureOpen()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedReader.ensureOpen()方法的具体详情如下:
包路径:java.io.BufferedReader
类名称:BufferedReader
方法名:ensureOpen

BufferedReader.ensureOpen介绍

[英]Checks to make sure that the stream has not been closed
[中]检查以确保流尚未关闭

代码示例

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Resets 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)
                 ? "Mark invalid"
                 : "Stream not marked");
    nextChar = markedChar;
    skipLF = markedSkipLF;
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Resets 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)
                 ? "Mark invalid"
                 : "Stream not marked");
    nextChar = markedChar;
    skipLF = markedSkipLF;
  }
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Marks 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. An attempt
 *                         to reset the stream after reading characters
 *                         up to this limit or beyond 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("Read-ahead limit < 0");
  }
  synchronized (lock) {
    ensureOpen();
    this.readAheadLimit = readAheadLimit;
    markedChar = nextChar;
    markedSkipLF = skipLF;
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Marks 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. An attempt
 *                         to reset the stream after reading characters
 *                         up to this limit or beyond 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("Read-ahead limit < 0");
  }
  synchronized (lock) {
    ensureOpen();
    this.readAheadLimit = readAheadLimit;
    markedChar = nextChar;
    markedSkipLF = skipLF;
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Reads a single character.
 *
 * @return The character read, as an integer in the range
 *         0 to 65535 (<tt>0x00-0xffff</tt>), or -1 if the
 *         end of the stream has been reached
 * @exception  IOException  If an I/O error occurs
 */
public int read() throws IOException {
  synchronized (lock) {
    ensureOpen();
    for (;;) {
      if (nextChar >= nChars) {
        fill();
        if (nextChar >= nChars)
          return -1;
      }
      if (skipLF) {
        skipLF = false;
        if (cb[nextChar] == '\n') {
          nextChar++;
          continue;
        }
      }
      return cb[nextChar++];
    }
  }
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Tells 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();
    /*
     * If newline needs to be skipped and the next char to be read
     * is a newline character, then just skip it right away.
     */
    if (skipLF) {
      /* Note that in.ready() will return true if and only if the next
       * read on the stream will not block.
       */
      if (nextChar >= nChars && in.ready()) {
        fill();
      }
      if (nextChar < nChars) {
        if (cb[nextChar] == '\n')
          nextChar++;
        skipLF = false;
      }
    }
    return (nextChar < nChars) || in.ready();
  }
}

代码示例来源:origin: jtulach/bck2brwsr

/**
 * Reads a single character.
 *
 * @return The character read, as an integer in the range
 *         0 to 65535 (<tt>0x00-0xffff</tt>), or -1 if the
 *         end of the stream has been reached
 * @exception  IOException  If an I/O error occurs
 */
public int read() throws IOException {
  synchronized (lock) {
    ensureOpen();
    for (;;) {
      if (nextChar >= nChars) {
        fill();
        if (nextChar >= nChars)
          return -1;
      }
      if (skipLF) {
        skipLF = false;
        if (cb[nextChar] == '\n') {
          nextChar++;
          continue;
        }
      }
      return cb[nextChar++];
    }
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

/**
 * Tells 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();
    /*
     * If newline needs to be skipped and the next char to be read
     * is a newline character, then just skip it right away.
     */
    if (skipLF) {
      /* Note that in.ready() will return true if and only if the next
       * read on the stream will not block.
       */
      if (nextChar >= nChars && in.ready()) {
        fill();
      }
      if (nextChar < nChars) {
        if (cb[nextChar] == '\n')
          nextChar++;
        skipLF = false;
      }
    }
    return (nextChar < nChars) || in.ready();
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

ensureOpen();
long r = n;
while (r > 0) {

代码示例来源:origin: jtulach/bck2brwsr

ensureOpen();
long r = n;
while (r > 0) {

代码示例来源:origin: org.apidesign.bck2brwsr/emul

ensureOpen();
boolean omitLF = ignoreLF || skipLF;

代码示例来源:origin: stackoverflow.com

ensureOpen();
boolean omitLF = ignoreLF || skipLF;

代码示例来源:origin: jtulach/bck2brwsr

ensureOpen();
boolean omitLF = ignoreLF || skipLF;

代码示例来源:origin: org.apidesign.bck2brwsr/emul

ensureOpen();
if ((off < 0) || (off > cbuf.length) || (len < 0) ||
  ((off + len) > cbuf.length) || ((off + len) < 0)) {

代码示例来源:origin: jtulach/bck2brwsr

ensureOpen();
if ((off < 0) || (off > cbuf.length) || (len < 0) ||
  ((off + len) > cbuf.length) || ((off + len) < 0)) {

相关文章