< prev index next >

src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java

Print this page

244 
245     /**
246      * Closes this {@code FileCacheImageInputStream}, closing
247      * and removing the cache file.  The source {@code InputStream}
248      * is not closed.
249      *
250      * @throws IOException if an error occurs.
251      */
252     public void close() throws IOException {
253         super.close();
254         disposerRecord.dispose(); // this will close/delete the cache file
255         stream = null;
256         cache = null;
257         cacheFile = null;
258         StreamCloser.removeFromQueue(closeAction);
259     }
260 
261     /**
262      * {@inheritDoc}
263      *
264      * @deprecated The {@code finalize} method has been deprecated.
265      *     Subclasses that override {@code finalize} in order to perform cleanup
266      *     should be modified to use alternative cleanup mechanisms and
267      *     to remove the overriding {@code finalize} method.
268      *     When overriding the {@code finalize} method, its implementation must explicitly
269      *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
270      *     See the specification for {@link Object#finalize()} for further
271      *     information about migration options.
272      */
273     @Deprecated(since="9")

274     protected void finalize() throws Throwable {
275         // Empty finalizer: for performance reasons we instead use the
276         // Disposer mechanism for ensuring that the underlying
277         // RandomAccessFile is closed/deleted prior to garbage collection
278     }
279 
280     private static class StreamDisposerRecord implements DisposerRecord {
281         private File cacheFile;
282         private RandomAccessFile cache;
283 
284         public StreamDisposerRecord(File cacheFile, RandomAccessFile cache) {
285             this.cacheFile = cacheFile;
286             this.cache = cache;
287         }
288 
289         public synchronized void dispose() {
290             if (cache != null) {
291                 try {
292                     cache.close();
293                 } catch (IOException e) {

244 
245     /**
246      * Closes this {@code FileCacheImageInputStream}, closing
247      * and removing the cache file.  The source {@code InputStream}
248      * is not closed.
249      *
250      * @throws IOException if an error occurs.
251      */
252     public void close() throws IOException {
253         super.close();
254         disposerRecord.dispose(); // this will close/delete the cache file
255         stream = null;
256         cache = null;
257         cacheFile = null;
258         StreamCloser.removeFromQueue(closeAction);
259     }
260 
261     /**
262      * {@inheritDoc}
263      *
264      * @deprecated Finalization has been deprecated for removal.  See
265      * {@link java.lang.Object#finalize} for background information and details
266      * about migration options.





267      */
268     @Deprecated(since="9", forRemoval=true)
269     @SuppressWarnings("removal")
270     protected void finalize() throws Throwable {
271         // Empty finalizer: for performance reasons we instead use the
272         // Disposer mechanism for ensuring that the underlying
273         // RandomAccessFile is closed/deleted prior to garbage collection
274     }
275 
276     private static class StreamDisposerRecord implements DisposerRecord {
277         private File cacheFile;
278         private RandomAccessFile cache;
279 
280         public StreamDisposerRecord(File cacheFile, RandomAccessFile cache) {
281             this.cacheFile = cacheFile;
282             this.cache = cache;
283         }
284 
285         public synchronized void dispose() {
286             if (cache != null) {
287                 try {
288                     cache.close();
289                 } catch (IOException e) {
< prev index next >