This week's book giveaway is in the OCAJP forum. We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line! See this thread for details.
javax.imageio.IIOException: Can't create an ImageInputStream!
posted 4 years ago
I am getting the exception from the title of this post whenever I try to run the following code:
File imageFile = new File (path);
BufferedImage img = ImageIO.read(imageFile);
I know that it a permissions-related problem not that the image has the read-only flag checked, but, that my user (at an OS level) does not have permission to open the image - I'm not even capable of opening it directly with the OS.
My question to YOU guys is, is there any way to check the permissions before trying to open a File. I do not want to use
File.canRead(), File.canWrite(), or File.canExecute() because they check whether the file has the read-only flag checked, but that does not work for me.
What I need to check is if the user has permissions over the object he's trying to open.