我有一个图片网址,例如,
String url = "http://XXXXXXX/img_High-Octane-Sauce-Company-JP5-400x1024.jpg";
我需要将此作为方法的输入,
ImageInputStream in = ImageIO.createImageInputStream( urlInputHere );
所以我可以在不使用图像缓冲区的情况下读取图像的宽度和高度。谁能告诉我该怎么做?
这是我阅读图像的方式
ImageInputStream in = ImageIO.createImageInputStream(resourceFile);
try {
final Iterator<ImageReader> readers = ImageIO.getImageReaders(in);
if (readers.hasNext()) {
ImageReader reader = readers.next();
try {
reader.setInput(in);
return new Dimension(reader.getWidth(0), reader.getHeight(0));
} finally {
reader.dispose();
}
}
} finally {
if (in != null) in.close();
}