Click to See Complete Forum and Search --> : URL, InputStream, to a File Object


Goodz13
July 10th, 2002, 09:00 AM
I have an Image in my JAR that I'm trying to access.

Actually I have an Auto Email Responder and I want to put an image in my email, But I need to get that image to a DataSource.

So what I have is:
InputStreamReader in = new InputStreamReader(getClass().getResourceAsStream("MyImage.gif"));

Now I need to get it to a File Object so I can do this:
DataSource imageDS = new FileDataSource(ImgFile);

ImgFile would be a File Object.

I know I can create a file and put everything from the InputStreamReader into it, then Open it as a File Object, but then what's the sence of having the Image in my Jar?

Anyway, any suggestions would be greatly appreciated.

Another question, What are the Code tags now? doesn't seem to work anymore.

Goodz13
July 16th, 2002, 12:39 PM
For anyone who's interested, I fixed my problem with:

DataSource imageDS = new URLDataSource(getClass().getResource("MyImage.gif"));