In my application the users must be able to load their own logo and display it in, for instance, their invoices. To find the image (the user logo) they want to use I use the JFileChooser. I succeed in writing the image, but the image comes in the image directory of my (Eclipse) workspace, not in the directory in my package structure, where the other image files reside. What can I do?
My directory structure under Windows XP (I know, ):
The image comes in my images directory. I want to get it in the foo/bar/images directory.
To get the images I use
I tried it with
which resulted in a FileNotFoundException
And I thought the location I wanted to save the image to (almost) correct (I doubt the 'file:\' part) in the Stack Trace.
Carey Brown wrote:Why open up the image and then save it? You could just copy the bytes from one file to another ignoring the fact that they just happen to represent an image.
Yes, you are right. But I was thinking to first show the image in the application, then to save it to the prescribed location, and lastly save the location to the database. However, copying the image first, and then opening is not something I thought about. But would I not have the same problem finding the location it has to be copied to?
Knute Snortum wrote:The "file:" part is coming from the URL class. I believe you can do something like imgURL.toString() to get rid of it.
I tried it by changing line 5 in the one for last piece of code to