String formatName,
File output) throws IOException {
if (output == null) {
throw new IllegalArgumentException("output == null!");
}
ImageOutputStream stream = null;
ImageWriter writer = getWriter(im, formatName);
if (writer == null) {
/* Do not make changes in the file system if we have
* no appropriate writer.
*/
return false;
}
try {
output.delete();
stream = createImageOutputStream(output);
} catch (IOException e) {
throw new IIOException("Can't create output stream!", e);
}
try {
return doWrite(im, writer, stream);
} finally {
stream.close();
}
}