< prev index next >
test/jdk/javax/imageio/plugins/shared/CanWriteSequence.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -44,10 +44,11 @@
*/
public final class CanWriteSequence {
private static File file;
private static FileOutputStream fos;
+ private static ImageOutputStream ios;
public static void main(final String[] args) throws Exception {
final IIORegistry registry = IIORegistry.getDefaultInstance();
final Iterator<ImageWriterSpi> iter =
registry.getServiceProviders(ImageWriterSpi.class,
@@ -63,11 +64,11 @@
private static void test(final ImageWriter writer) throws Exception {
try {
file = File.createTempFile("temp", ".img");
fos = new FileOutputStream(file);
- final ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
+ ios = ImageIO.createImageOutputStream(fos);
writer.setOutput(ios);
final IIOMetadata data = writer.getDefaultStreamMetadata(null);
if (writer.canWriteSequence()) {
writer.prepareWriteSequence(data);
@@ -81,14 +82,16 @@
}
}
} finally {
writer.dispose();
if (file != null) {
+ if (ios != null) {
+ ios.close();
+ }
if (fos != null) {
fos.close();
}
Files.delete(file.toPath());
}
}
}
}
-
< prev index next >