The close() method has already defined in the Closeable interface, why Channel redefines it again?
package java.io;
import java.io.IOException;
public interface Closeable extends AutoCloseable {
public void close() throws IOException;
}
package java.nio.channels;
import java.io.IOException;
import java.io.Closeable;
public interface Channel extends Closeable {
public boolean isOpen();
public void close() throws IOException;
}
You have unfortunately not copied the most important parts - the JavaDoc.
The JavaDoc of
Channel#close()
clarifies quite a bit of the channel-specific details for this method, for example that subsequent operations throwClosedChannelException
, and how this method behaves when multiple threads are involved, especially blocking behavior.Also,
Channel
predatesCloseable
(introduced in 1.4,Closeable
in 1.5) and was retrofitted with that interface.