# Closeable

public interface **Closeable** implements [AutoCloseable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html)

|---|---|---|
| Known Indirect Subclasses [AbstractInterruptibleChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html), [AbstractSelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html), [AbstractSelector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelector.html), [AsynchronousByteChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousByteChannel.html), [AsynchronousChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannel.html), [AsynchronousFileChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousFileChannel.html), [AsynchronousServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousServerSocketChannel.html), [AsynchronousSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousSocketChannel.html), [BufferedInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedInputStream.html), [BufferedOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedOutputStream.html), [BufferedReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedReader.html), [BufferedWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedWriter.html), [ByteArrayInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ByteArrayInputStream.html), [ByteArrayOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ByteArrayOutputStream.html), [ByteChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ByteChannel.html), and [82 others.](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable#) |---|---| | [AbstractInterruptibleChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractInterruptibleChannel.html) | Base implementation class for interruptible channels. | | [AbstractSelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelectableChannel.html) | Base implementation class for selectable channels. | | [AbstractSelector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/spi/AbstractSelector.html) | Base implementation class for selectors. | | [AsynchronousByteChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousByteChannel.html) | An asynchronous channel that can read and write bytes. | | [AsynchronousChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousChannel.html) | A channel that supports asynchronous I/O operations. | | [AsynchronousFileChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousFileChannel.html) | An asynchronous channel for reading, writing, and manipulating a file. | | [AsynchronousServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousServerSocketChannel.html) | An asynchronous channel for stream-oriented listening sockets. | | [AsynchronousSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/AsynchronousSocketChannel.html) | An asynchronous channel for stream-oriented connecting sockets. | | [BufferedInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedInputStream.html) | A `BufferedInputStream` adds functionality to another input stream-namely, the ability to buffer the input and to support the `mark` and `reset` methods. | | [BufferedOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedOutputStream.html) | The class implements a buffered output stream. | | [BufferedReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedReader.html) | Reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. | | [BufferedWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/BufferedWriter.html) | Writes text to a character-output stream, buffering characters so as to provide for the efficient writing of single characters, arrays, and strings. | | [ByteArrayInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ByteArrayInputStream.html) | A `ByteArrayInputStream` contains an internal buffer that contains bytes that may be read from the stream. | | [ByteArrayOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ByteArrayOutputStream.html) | This class implements an output stream in which the data is written into a byte array. | | [ByteChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ByteChannel.html) | A channel that can read and write bytes. | | [Channel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Channel.html) | A nexus for I/O operations. | | [CharArrayReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/CharArrayReader.html) | This class implements a character buffer that can be used as a character-input stream. | | [CharArrayWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/CharArrayWriter.html) | This class implements a character buffer that can be used as an Writer. | | [CheckedInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/CheckedInputStream.html) | An input stream that also maintains a checksum of the data being read. | | [CheckedOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/CheckedOutputStream.html) | An output stream that also maintains a checksum of the data being written. | | [CipherInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/CipherInputStream.html) | A CipherInputStream is composed of an InputStream and a Cipher so that read() methods return data that are read in from the underlying InputStream but have been additionally processed by the Cipher. | | [CipherOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/CipherOutputStream.html) | A CipherOutputStream is composed of an OutputStream and a Cipher so that write() methods first process the data before writing them out to the underlying OutputStream. | | [DataInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/DataInputStream.html) | A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. | | [DataOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/DataOutputStream.html) | A data output stream lets an application write primitive Java data types to an output stream in a portable way. | | [DatagramChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/DatagramChannel.html) | A selectable channel for datagram-oriented sockets. | | [DatagramSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/DatagramSocket.html) | This class represents a socket for sending and receiving datagram packets. | | [DeflaterInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterInputStream.html) | Implements an input stream filter for compressing data in the "deflate" compression format. | | [DeflaterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/DeflaterOutputStream.html) | This class implements an output stream filter for compressing data in the "deflate" compression format. | | [DigestInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/DigestInputStream.html) | A transparent stream that updates the associated message digest using the bits going through the stream. | | [DigestOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/DigestOutputStream.html) | A transparent stream that updates the associated message digest using the bits going through the stream. | | [DirectoryStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/DirectoryStream.html)\<T\> | An object to iterate over the entries in a directory. | | [FileChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/FileChannel.html) | A channel for reading, writing, mapping, and manipulating a file. | | [FileInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FileInputStream.html) | A `FileInputStream` obtains input bytes from a file in a file system. | | [FileOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FileOutputStream.html) | A file output stream is an output stream for writing data to a `File` or to a `FileDescriptor`. | | [FileReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FileReader.html) | Convenience class for reading character files. | | [FileSystem](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/FileSystem.html) | Provides an interface to a file system and is the factory for objects to access files and other objects in the file system. | | [FileWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FileWriter.html) | Convenience class for writing character files. | | [FilterInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterInputStream.html) | A `FilterInputStream` contains some other input stream, which it uses as its basic source of data, possibly transforming the data along the way or providing additional functionality. | | [FilterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterOutputStream.html) | This class is the superclass of all classes that filter output streams. | | [FilterReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterReader.html) | Abstract class for reading filtered character streams. | | [FilterWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/FilterWriter.html) | Abstract class for writing filtered character streams. | | [Formatter](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Formatter.html) | An interpreter for printf-style format strings. | | [GZIPInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPInputStream.html) | This class implements a stream filter for reading compressed data in the GZIP file format. | | [GZIPOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/GZIPOutputStream.html) | This class implements a stream filter for writing compressed data in the GZIP file format. | | [GatheringByteChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/GatheringByteChannel.html) | A channel that can write bytes from a sequence of buffers. | | [InflaterInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/InflaterInputStream.html) | This class implements a stream filter for uncompressing data in the "deflate" compression format. | | [InflaterOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/InflaterOutputStream.html) | Implements an output stream filter for uncompressing data stored in the "deflate" compression format. | | [InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html) | This abstract class is the superclass of all classes representing an input stream of bytes. | | [InputStreamReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStreamReader.html) | An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/charset/Charset.html`. | | [InterruptibleChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/InterruptibleChannel.html) | A channel that can be asynchronously closed and interrupted. | | [JarFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/jar/JarFile.html) | The `JarFile` class is used to read the contents of a jar file from any file that can be opened with `java.io.RandomAccessFile`. | | [JarInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/jar/JarInputStream.html) | The `JarInputStream` class is used to read the contents of a JAR file from any input stream. | | [JarOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/jar/JarOutputStream.html) | The `JarOutputStream` class is used to write the contents of a JAR file to any output stream. | | [LineNumberInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/LineNumberInputStream.html) | *This class is deprecated. This class incorrectly assumes that bytes adequately represent characters. As of JDK 1.1, the preferred way to operate on character streams is via the new character-stream classes, which include a class for counting line numbers.* | | [LineNumberReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/LineNumberReader.html) | A buffered character-input stream that keeps track of line numbers. | | [MulticastChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/MulticastChannel.html) | A network channel that supports Internet Protocol (IP) multicasting. | | [MulticastSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/MulticastSocket.html) | The multicast datagram socket class is useful for sending and receiving IP multicast packets. | | [NetworkChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/NetworkChannel.html) | A channel to a network socket. | | [ObjectInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectInputStream.html) | An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream. | | [ObjectOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/ObjectOutputStream.html) | An ObjectOutputStream writes primitive data types and graphs of Java objects to an OutputStream. | | [OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) | This abstract class is the superclass of all classes representing an output stream of bytes. | | [OutputStreamWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStreamWriter.html) | A class for turning a character stream into a byte stream. | | [Pipe.SinkChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.SinkChannel.html) | A channel representing the writable end of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.html`. | | [Pipe.SourceChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.SourceChannel.html) | A channel representing the readable end of a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Pipe.html`. | | [PipedInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PipedInputStream.html) | Receives information from a communications pipe. | | [PipedOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PipedOutputStream.html) | Places information on a communications pipe. | | [PipedReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PipedReader.html) | Piped character-input streams. | | [PipedWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PipedWriter.html) | Piped character-output streams. | | [PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) | A `PrintStream` adds functionality to another output stream, namely the ability to print representations of various data values conveniently. | | [PrintWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintWriter.html) | Prints formatted representations of objects to a text-output stream. | | [PushbackInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PushbackInputStream.html) | A `PushbackInputStream` adds functionality to another input stream, namely the ability to "push back" or "unread" one byte. | | [PushbackReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PushbackReader.html) | A character-stream reader that allows characters to be pushed back into the stream. | | [RandomAccessFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/RandomAccessFile.html) | Instances of this class support both reading and writing to a random access file. | | [ReadableByteChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ReadableByteChannel.html) | A channel that can read bytes. | | [Reader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Reader.html) | Abstract class for reading character streams. | | [SSLServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLServerSocket.html) | This class extends `ServerSocket`s and provides secure server sockets using protocols such as the Secure Sockets Layer (SSL) or Transport Layer Security (TLS) protocols. | | [SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html) | This class extends `Socket`s and provides secure socket using protocols such as the "Secure Sockets Layer" (SSL) or IETF "Transport Layer Security" (TLS) protocols. | | [Scanner](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Scanner.html) | A simple text scanner which can parse primitive types and strings using regular expressions. | | [ScatteringByteChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ScatteringByteChannel.html) | A channel that can read bytes into a sequence of buffers. | | [SecureDirectoryStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/SecureDirectoryStream.html)\<T\> | A `DirectoryStream` that defines operations on files that are located relative to an open directory. | | [SeekableByteChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SeekableByteChannel.html) | A byte channel that maintains a current *position* and allows the position to be changed. | | [SelectableChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html) | A channel that can be multiplexed via a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html`. | | [Selector](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/Selector.html) | A multiplexor of `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SelectableChannel.html` objects. | | [SequenceInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/SequenceInputStream.html) | A `SequenceInputStream` represents the logical concatenation of other input streams. | | [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html) | This class implements server sockets. | | [ServerSocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/ServerSocketChannel.html) | A selectable channel for stream-oriented listening sockets. | | [Socket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html) | This class implements client sockets (also called just "sockets"). | | [SocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html) | A selectable channel for stream-oriented connecting sockets. | | [StringBufferInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/StringBufferInputStream.html) | *This class is deprecated. This class does not properly convert characters into bytes. As of JDK 1.1, the preferred way to create a stream from a string is via the `StringReader` class.* | | [StringReader](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/StringReader.html) | A character stream whose source is a string. | | [StringWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/StringWriter.html) | A character stream that collects its output in a string buffer, which can then be used to construct a string. | | [WatchService](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/WatchService.html) | A watch service that *watches* registered objects for changes and events. | | [WritableByteChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/WritableByteChannel.html) | A channel that can write bytes. | | [Writer](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Writer.html) | Abstract class for writing to character streams. | | [ZipFile](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipFile.html) | This class is used to read entries from a zip file. | | [ZipInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipInputStream.html) | This class implements an input stream filter for reading files in the ZIP file format. | | [ZipOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/zip/ZipOutputStream.html) | This class implements an output stream filter for writing files in the ZIP file format. | |||

A `Closeable` is a source or destination of data that can be closed.
The close method is invoked to release resources that the object is
holding (such as open files).

### Public Method Summary

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html#close())() Closes this stream and releases any system resources associated with it. |

### Inherited Method Summary

From interface [java.lang.AutoCloseable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html#close())() Closes this resource, relinquishing any underlying resources. |

## Public Methods

#### public abstract void
**close**
()

Closes this stream and releases any system resources associated
with it. If the stream is already closed then invoking this
method has no effect.

As noted in `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html#close()`, cases where the
close may fail require careful attention. It is strongly advised
to relinquish the underlying resources and to internally
*mark* the `Closeable` as closed, prior to throwing
the `IOException`.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs |
|---|---|