Top Description Methods
java.io

public Interface Closeable

extends AutoCloseable
Known Direct Subinterfaces
java.lang.module.ModuleReader, java.nio.channels.Channel, java.nio.file.DirectoryStream, java.nio.file.WatchService, jdk.internal.module.ModulePatcher.ResourceFinder, sun.nio.ch.Port.PollableChannel
Known Direct Implementers
java.io.InputStream, java.io.OutputStream, java.io.PrintStream, java.io.RandomAccessFile, java.io.Reader, java.io.Writer, java.net.DatagramSocket, java.net.ServerSocket, java.net.Socket, java.net.URLClassLoader, java.nio.channels.Selector, java.nio.file.FileSystem, java.nio.file.FileTreeIterator, java.nio.file.FileTreeWalker, java.util.zip.ZipFile, com.sun.crypto.provider.PKCS12PBECipherCore.KeyAndIv, jdk.internal.loader.URLClassPath.Loader, sun.net.ftp.FtpClient, sun.net.ftp.impl.FtpClient.FtpFileIterator, sun.security.ssl.InputRecord, sun.security.ssl.OutputRecord, java.util.Formatter, java.util.Scanner
Imports
java.io.IOException

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).
Since
1.5

Method Summary

Modifier and TypeMethod and Description
public void
close()

Redeclares java.lang.AutoCloseable.close.

Closes this stream and releases any system resources associated with it.

Method Detail

closeback to summary
public void close() throws IOException

Redeclares java.lang.AutoCloseable.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 AutoCloseable#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.

Exceptions
IOException:
if an I/O error occurs