java.io

Interface Closeable

Known Subinterfaces:
ByteChannel, Channel, GatheringByteChannel, InterruptibleChannel, ReadableByteChannel, ScatteringByteChannel, WritableByteChannel
Known Implementing Classes:
AbstractInterruptibleChannel, AbstractSelectableChannel, ASCIIReader, AudioInputStream, AutoCloseInputStream, Base64.InputStream, Base64.OutputStream, BlockingInputStream, BodyContent, BufferedInputStream, BufferedOutputStream, BufferedReader, BufferedWriter, ByteArrayInputStream, ByteArrayOutputStream, ByteArrayOutputStream, ByteBuffer, ByteIteratorInputStream, ByteSequence, CallbackWriter, CharArrayReader, CharArrayWriter, CharIteratorReader, CharSequenceReader, CheckedInputStream, CheckedOutputStream, ChunkedInputStream, ChunkedOutputStream, ClassLoaderObjectInputStream, ClosedInputStream, ClosedOutputStream, CloseShieldInputStream, CloseShieldOutputStream, CodebaseAwareObjectInputStream, ContentLengthInputStream, CountingInputStream, CountingOnlyOutputStream, CountingOutputStream, DatagramChannel, DataInputStream, DataOutputStream, DeferredFileOutputStream, DeflaterOutputStream, DemuxInputStream, DemuxOutputStream, DigestInputStream, DigestOutputStream, DocumentInputStream, DocumentOutputStream, DotTerminatedMessageReader, DotTerminatedMessageWriter, FastByteArrayOutputStream, FileBufferedOutputStream, FileBufferedOutputStream.DataStream, FileChannel, FileInputStream, FileInputStreamProxy, FileOutputStream, FileOutputStreamProxy, FileReader, FileWriter, FileWriterWithEncoding, FilterInputStream, FilterOutputStream, FilterReader, FilterServletOutputStream, FilterWriter, Formatter, FromNetASCIIInputStream, FromNetASCIIOutputStream, GZIPInputStream, GZIPOutputStream, HTML2TextReader, InflaterInputStream, InputStream, InputStreamAdapter, InputStreamReader, JarInputStream, JarOutputStream, JRAbstractLRUVirtualizer.ClassLoaderAnnotationObjectInputStream, JRAbstractLRUVirtualizer.ClassLoaderAnnotationObjectOutputStream, JRPdfExporter.NullOutputStream, JspWriter, Latin1Reader, LimitedInputStream, LineNumberInputStream, LineNumberReader, LockableFileWriter, LogStream, MonitorInputStream, MonitorOutputStream, MultipartStream.ItemInputStream, NullInputStream, NullOutputStream, NullReader, NullWriter, ObjectInputStream, ObjectOutputStream, OutputStream, OutputStreamCounter, OutputStreamEncryption, OutputStreamWriter, Pipe.SinkChannel, Pipe.SourceChannel, PipedInputStream, PipedOutputStream, PipedReader, PipedWriter, PngDecodingDataStream, PngInputStream, PortletServletInputStream, PortletServletOutputStream, PrintStream, PrintWriter, ProgressMonitorInputStream, PropertiesConfiguration.PropertiesReader, PropertiesConfiguration.PropertiesWriter, ProxyInputStream, ProxyOutputStream, ProxyReader, ProxyWriter, PushbackInputStream, PushbackReader, RamFileOutputStream, RandomAccessFile, Reader, ReaderInputStream, RecordInputStream, ResponseStream, ResponseWriter, RubyOutputStream, SelectableChannel, SequenceInputStream, ServerSocketChannel, ServletInputStream, ServletOutputStream, SingleCharReader, SlowInputStream, SlowOutputStream, SocketChannel, SocketInputStream, SocketOutputStream, StringBufferInputStream, StringReader, StringWriter, StrutsBodyContent, StrutsMockBodyContent, StrutsMockJspWriter, SubstitutionTextReader, SwappedDataInputStream, TeeInputStream, TeeOutputStream, ThresholdingOutputStream, ToNetASCIIInputStream, ToNetASCIIOutputStream, UCSReader, UTF8Reader, Writer, XMLEntityManager.RewindableInputStream, XmlFixerReader, XMLFormatter, XmlReader, ZipInputStream, ZipOutputStream

public interface Closeable

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

void
close()
Closes this stream and releases any system resources associated with it.

Method Details

close

public void close()
            throws IOException
Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.
Throws:
IOException - if an I/O error occurs
Usages and Demos :

View More Examples of close()
   1: 
   2:     public static void close(Closeable closeable) throws IOException {
   3:         ...
   4:         if (closeable instanceof InputStream) {
   5:         ...
   6:             ((InputStream) closeable).close();
   7:         } else if (closeable instanceof OutputStream) {
   8:         ...
   9:             ((OutputStream) closeable).close();

View Full Code Here
   1: 
   2: import java.io.Closeable;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:             in.close();
   7: 
   8:         ...
   9: 
  10:     private static void close(Closeable closeable)
  11:     {
  12:         ...
  13:             {
  14:                 closeable.close();

View Full Code Here
   1: 
   2: import java.io.Closeable;
   3: import java.net.ServerSocket;
   4:         ...
   5:                     {
   6:                         socket.close();
   7:                     }
   8:         ...
   9:                     {
  10:                         socket.close();
  11:                     }
  12:         ...
  13:                     {
  14:                         socket.close();

View Full Code Here
   1:             {
   2:                 in.close();
   3:             }
   4:         ...
   5:             {
   6:                 out.close();
   7:             }
   8:         ...
   9:             {
  10:                 r.close();
  11:             }
  12:         ...
  13: 
  14:     public static void closeQuietly(Closeable closeable)

View Full Code Here
   1: 
   2: import java.io.Closeable;
   3: import java.io.FileInputStream;
   4:         ...
   5:             oos.writeObject(this);
   6:             oos.close();
   7:         } finally {
   8:         ...
   9:             Events events = (Events) ois.readObject();
  10:             ois.close();
  11:             ois = null;
  12:         ...
  13: 
  14:     private static void close(Closeable toClose) {

View Full Code Here