Hi,
My Java program needs to do a lot of reading from text files or writing
to text files. I always provide the absolute path to those files. Things
are working.
But, I have heard that Class.getResourceAsStream() can do things more
intelligent: after specifying the path, the Java will search for the
file along the path to find the file with name matches what I want. This
will be useful, since my files have unique file names.
Is my understanding correct? I don't see many people using it and few
examples out there to help me start it. Could you give me some help?
Thank you.
Manish Pandit - 26 Jan 2007 19:21 GMT
> Hi,
>
[quoted text clipped - 10 lines]
> examples out there to help me start it. Could you give me some help?
> Thank you.
Yes, your understanding is correct that the vm will look for the
resource, and return you an input stream for it. However, the resource
will not be searched in $PATH if that is what you mean by "path". You
will have to ensure that the resource or the jar file containing the
resource is in the *classpath*.
-cheers,
Manish