What is the deal with the Closeable and Flushable interfaces?

John Zukowski

The ability to close() or flush() an object (typeically a stream) has been factored out into single method interfaces, Closeable and Flushable, respectively. Given that you sometimes need to operate on different types of objects, like InputStream, OutputStream, RandomAccessFile, and Formatter, when your done working with the class, you don't always care what it was you operated on. Thus, instead of having different "done" like methods to close or fLush the object, you can deal with just one for all types, as long as they implement Closeable or Flushable.