superthang
New Member
I would like to check if the file I am reading in from a directory is a jpg but I do not want to simply check the extension. I am thinking an alternative is to read the header. I have done some research and I want to use\[code\]ImageIO.read\[/code\]I have seen the example \[code\] String directory="/directory"; BufferedImage img = null;try { img = ImageIO.read(new File(directory)); } catch (IOException e) { //it is not a jpg file }\[/code\]I am not sure where to go from here, it takes in the entire directory... but I need each jpg file in the directory. Can someone tell me what is wrong with my code or what additions need to be made?Thank you!