samedi 20 décembre 2014

why close() method is not core functionality of InputStream/OutputStream in java?


It make sense to see flush() method as part of Flushable interface, because not every output stream requires flushing the output stream functionality.


But, close() method seem to be a core functionality of any input stream and output stream. Is that correct?


enter image description here


As per below definition, close() is not part of core functionality of I/O stream, as it gets implemented via an interface



public abstract class InputStream implements Closeable {}

public abstract class OutputStream implements Closeable, Flushable {}


How do you expain this?





Aucun commentaire:

Enregistrer un commentaire