< prev index next >
src/java.desktop/share/classes/javax/imageio/ImageIO.java
Print this page
@@ -1350,10 +1350,15 @@
if (input == null) {
throw new IllegalArgumentException("input == null!");
}
ImageInputStream stream = createImageInputStream(input);
+
+ if (stream == null) {
+ throw new IIOException("Can't create an ImageInputStream!");
+ }
+
BufferedImage bi = read(stream);
if (bi == null) {
stream.close();
}
return bi;
@@ -1396,10 +1401,15 @@
istream = input.openStream();
} catch (IOException e) {
throw new IIOException("Can't get input stream from URL!", e);
}
ImageInputStream stream = createImageInputStream(istream);
+
+ if (stream == null) {
+ throw new IIOException("Can't create an ImageInputStream!");
+ }
+
BufferedImage bi;
try {
bi = read(stream);
if (bi == null) {
stream.close();
@@ -1533,10 +1543,14 @@
stream = createImageOutputStream(output);
} catch (IOException e) {
throw new IIOException("Can't create output stream!", e);
}
+ if (stream == null) {
+ throw new IIOException("Can't create an ImageOutputStream!");
+ }
+
try {
return doWrite(im, writer, stream);
} finally {
stream.close();
}
@@ -1575,10 +1589,14 @@
stream = createImageOutputStream(output);
} catch (IOException e) {
throw new IIOException("Can't create output stream!", e);
}
+ if (stream == null) {
+ throw new IIOException("Can't create an ImageOutputStream!");
+ }
+
try {
return doWrite(im, getWriter(im, formatName), stream);
} finally {
stream.close();
}
< prev index next >