IntelliJ Java IDE
The moose likes I/O and Streams and the fly likes ImageIO and .exists can't find file. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "ImageIO and .exists can Watch "ImageIO and .exists can New topic
Author

ImageIO and .exists can't find file.

Nickalos Klemer
Greenhorn

Joined: Nov 13, 2011
Posts: 2


Is there any way to check exactly where in the system it's trying to load the image from?
I am using Iltellij if it matters.


My problem is that when I compile and run the whole thing, even though the file(s) it tries to load does exists, the program can't seem to find it.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2329
Do you really want to access a file named "filename" (and not the one specified by the filename parameter passed into the method)?
Nickalos Klemer
Greenhorn

Joined: Nov 13, 2011
Posts: 2
Tim Moores wrote:Do you really want to access a file named "filename" (and not the one specified by the filename parameter passed into the method)?

Oh, oops.
Even after I fixed "boolean exists = (new File(fileName)).exists();" the problem still persists.
The reason I put that exists thing up anyway was to try to narrow down this problem.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2329
ImageIO.read(PDB.class.getResource(fileName))

This looks odd. Why are you using the resource loading mechanism instead of "ImageIO.read(fileName)"? That would cause the file to be searched for at a different location than what the file name specifies.

Also make sure that the account running this code has read access to all (intermediate) directories and files.
 
 
subject: ImageIO and .exists can't find file.
 
Threads others viewed
copy paste java object using System clipboard
Loading image in Canvas (Urgent)
Ip camera view
Help with an Image Button
Copy and paste java objects using System clipboard
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture