为什么InputStream.markSupported总是返回false [android]

时间:2016-03-19 01:53:23

标签: android

/**
 * Indicates whether this stream supports the {@code mark()} and
 * {@code reset()} methods. The default implementation returns 
 * {@code false}.
 *
 * @return always {@code false}.
 * @see #mark(int)
 * @see #reset()
 */
public boolean markSupported() {
    return false;
}


public void mark(int readlimit) {
    /* empty */
}

public synchronized void reset() throws IOException {
    throw new IOException();
}

注释表示markSupported()指示此流是否支持mark()和reset()方法。

但它总是返回假。

他们之间的联系是如何产生的?

由于

1 个答案:

答案 0 :(得分:0)

正如@Mike解释的那样,抽象类 InputStream本身不支持mark,但是extend InputStream@Override的子类是方法您在问题中发帖了。

InputStream(例如BufferedInputStream)支持标记,并覆盖mark()markSupported()reset()方法。