public interface Disposable
dispose()method allows any resources held by this object to be released. The result of calling any other method subsequent to a call to this method is undefined.
Closeableinterfaces. While very similar, those two interfaces serve slightly different purposes. The
Closeableinterface closes a stream or a connection, but some classes allow the object to be reused with a different stream. However once an object has been disposed, it can not be used anymore.
ImageWriterallow to reuse the same instance many times for reading or writing different images in the same format. New streams can be created, given to the
ImageWriterand closed many times as long as
dispose()has not been invoked.
dispose()does not throw any checked exception. That method may be invoked in a background thread performing cleanup tasks, which would not know what to do in case of failure. Error during
dispose()execution should not result in any lost of data.
Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.