Closeable, Readable, Flushable, Appendable

Posted Keep

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Closeable, Readable, Flushable, Appendable相关的知识,希望对你有一定的参考价值。

Closeable:

package java.io;

import java.io.IOException;

public interface Closeable {
    /**
     * Closes this stream and releases any system resources associated
     * with it. If the stream is already closed then invoking this 
     * method has no effect. 
     */
    public void close() throws IOException;
}

Readable:

package java.lang;

import java.io.IOException;

public interface Readable {

    /**
     * Attempts to read characters into the specified character buffer.
     * The buffer is used as a repository of characters as-is: the only
     * changes made are the results of a put operation. No flipping or
     * rewinding of the buffer is performed.
     */
    public int read(java.nio.CharBuffer cb) throws IOException;
}
Flushable:
package java.io;

import java.io.IOException;

public interface Flushable {

    /**
     * Flushes this stream by writing any buffered output to the underlying stream.
     */
    void flush() throws IOException;
}

Appendable:

package java.lang;

import java.io.IOException;

public interface Appendable {

    /**
     * Appends the specified character sequence to this Appendable.
     * @return  A reference to this Appendable
     */
    Appendable append(CharSequence csq) throws IOException;

    /**
     * Appends a subsequence of the specified character sequence to this Appendable.
     * @return  A reference to this Appendable
     */
    Appendable append(CharSequence csq, int start, int end) throws IOException;

    /**
     * Appends the specified character to this Appendable.
     * @return  A reference to this Appendable
     */
    Appendable append(char c) throws IOException;
}

 转自:https://blog.csdn.net/jjavaboy/article/details/43093435

以上是关于Closeable, Readable, Flushable, Appendable的主要内容,如果未能解决你的问题,请参考以下文章

接口 Closeable

Java 接口Closeable

Closeable 和 AutoCloseable close() 方法的执行顺序

实现 Closeable 或实现 AutoCloseable

是否将 Closeable 的新实例分配给先前创建的实例,关闭先前的实例?

銆愯浆銆慾ava.io.Closeable鎺ュ彛