Module java.base
Package java.io

Interface Closeable

所有超级接口:
AutoCloseable
所有已知子接口:
AsynchronousByteChannel, AsynchronousChannel, ByteChannel, Channel, DirectoryStream<T>, GatheringByteChannel, ImageInputStream, ImageOutputStream, InterruptibleChannel, JavaFileManager, JMXConnector, ModuleReader, MulticastChannel, NetworkChannel, ReadableByteChannel, RMIConnection, ScatteringByteChannel, SecureDirectoryStream<T>, SeekableByteChannel, StandardJavaFileManager, WatchService, WritableByteChannel
所有已知实现类:
AbstractInterruptibleChannel, AbstractSelectableChannel, AbstractSelector, AsynchronousFileChannel, AsynchronousServerSocketChannel, AsynchronousSocketChannel, AudioInputStream, BufferedInputStream, BufferedOutputStream, BufferedReader, BufferedWriter, ByteArrayInputStream, ByteArrayOutputStream, CharArrayReader, CharArrayWriter, CheckedInputStream, CheckedOutputStream, CipherInputStream, CipherOutputStream, DatagramChannel, DatagramSocket, DataInputStream, DataOutputStream, DeflaterInputStream, DeflaterOutputStream, DigestInputStream, DigestOutputStream, FileCacheImageInputStream, FileCacheImageOutputStream, FileChannel, FileImageInputStream, FileImageOutputStream, FileInputStream, FileOutputStream, FileReader, FileSystem, FileWriter, FilterInputStream, FilterOutputStream, FilterReader, FilterWriter, Formatter, ForwardingJavaFileManager, GZIPInputStream, GZIPOutputStream, ImageInputStreamImpl, ImageOutputStreamImpl, InflaterInputStream, InflaterOutputStream, InputStream, InputStreamReader, JarFile, JarInputStream, JarOutputStream, LineNumberInputStream, LineNumberReader, LogStream, MemoryCacheImageInputStream, MemoryCacheImageOutputStream, MLet, MulticastSocket, ObjectInputStream, ObjectOutputStream, OutputStream, OutputStreamWriter, Pipe.SinkChannel, Pipe.SourceChannel, PipedInputStream, PipedOutputStream, PipedReader, PipedWriter, PrintStream, PrintWriter, PrivateMLet, ProgressMonitorInputStream, PushbackInputStream, PushbackReader, RandomAccessFile, Reader, Recording, RecordingFile, RMIConnectionImpl, RMIConnectionImpl_Stub, RMIConnector, RMIJRMPServerImpl, RMIServerImpl, Scanner, SctpChannel, SctpMultiChannel, SctpServerChannel, SelectableChannel, Selector, SequenceInputStream, ServerSocket, 服务器套接字通道, 套接字, 套接字通道, SSL服务器套接字, SSL套接字, 字符串缓冲输入流, 字符串读取器, 字符串写入器, URL类加载器, 写入器, ZIP文件, ZIP输入流, ZIP输出流

public interface Closeable extends AutoCloseable
Closeable 是可以关闭的数据源或目的地。调用 close 方法来释放对象持有的资源(如打开的文件)。
自 JDK 版本:
1.5
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    close()
    关闭此流并释放与其关联的任何系统资源。
  • Method Details

    • close

      void close() throws IOException
      关闭此流并释放与其关联的任何系统资源。如果流已经关闭,则调用此方法不会产生任何效果。

      AutoCloseable.close() 中所述,关闭可能失败的情况需要特别注意。强烈建议在抛出 IOException 之前放弃底层资源并在内部将 Closeable 标记为已关闭。

      指定者:
      close 在接口 AutoCloseable
      抛出:
      IOException - 如果发生 I/O 错误