Hi everyone,
I am trying to get the heigh and width of images (via a url) in Java without an ImageObserver. My current code is:
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
File xmlImages = new File("C:\\images.xml");
BufferedReader br = new BufferedReader(new FileReader(xmlImages));
File output = new File("C:\\images.csv");
BufferedWriter bw = new BufferedWriter(new FileWriter(output));
StringBuffer sb = new StringBuffer();
String line = null;
String newline = System.getProperty("line.separator");
while((line = br.readLine()) != null){
if(line.contains("http")){
URL url = new URL(line.)
Image img = Toolkit.getDefaultToolkit().getImage(url);
sb.append(line + ","+ img.getHeight(null) + "," + img.getWidth(Null) + newline);
}
}
br.close();
bw.write(sb.toString());
bw.close();
}
When i go into debug mode I am able to see that the image was loaded and I can see the Heigh and the Width of the image, but I can't seem to return them. The getHeigh and getWidth methods require an Image Observer, which I dont have. Thank you in advance.