Hello all,
How one finds a file on the disk using the ClassLoader?
It is not necessarily a java class, and using an absolute path is not
an option since it can reside under different roots.
What is certain is the file's name and its relative path to the
ClassLoader.
thank you,
Rami
Thomas Fritsch - 11 Jun 2007 12:22 GMT
ramiab3@gmail.com schrieb:
> How one finds a file on the disk using the ClassLoader?
>
> It is not necessarily a java class, and using an absolute path is not
> an option since it can reside under different roots.
> What is certain is the file's name and its relative path to the
> ClassLoader.
ClassLoader has 2 methods for your purpose:
public URL getResource(String name)
public InputStream getResourceAsStream(String name)
See <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html>

Signature
Thomas
Lew - 11 Jun 2007 12:28 GMT
> ramiab3@gmail.com schrieb:
>> How one finds a file on the disk using the ClassLoader?
[quoted text clipped - 7 lines]
> public InputStream getResourceAsStream(String name)
> See <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html>
In general when one has a question about a particular class or package in the
standard API one should refer to the API docs.

Signature
Lew
Arne Vajhøj - 12 Jun 2007 02:18 GMT
> How one finds a file on the disk using the ClassLoader?
>
> It is not necessarily a java class, and using an absolute path is not
> an option since it can reside under different roots.
> What is certain is the file's name and its relative path to the
> ClassLoader.
Do you need to read the content of the file or do you need to
find the absolute path of the file ?
Arne
cyprian - 12 Jun 2007 11:02 GMT
On Jun 12, 2:18 am, Arne Vajh?j <a...@vajhoej.dk> wrote:
> rami...@gmail.com wrote:
> > How one finds a file on the disk using the ClassLoader?
[quoted text clipped - 8 lines]
>
> Arne
where's the API?
Arne Vajhøj - 13 Jun 2007 03:25 GMT
>> rami...@gmail.com wrote:
>>> How one finds a file on the disk using the ClassLoader?
[quoted text clipped - 5 lines]
>> find the absolute path of the file ?
> where's the API?
If you have a new question I recommend you create a new thread.
Arne