09-20-2011 04:39 AM
How to load resources from another module such as a library?
I knew the method Class.forName(ClassPath).getResourceAsStream(file
In project A I writed as follows:
Class myClass = Class.forName("Test.MyClass"); //in another module
InputStream inStream = myClass.getResourceAsStream("/Test.txt");The myClass is not null, but the inStream always be null.
I don't know I was wrong or the method itself can not load resources from another module....
Anyone give me some suggestions.
Thanks a lot!
09-20-2011 05:40 AM
Did you try the same code to load resource from your own module ?
In my opinion, the problem is in wrong resources URL ...
09-20-2011 05:51 AM
Yes, i have. And it works.
But i can't load other module's txt files.
09-20-2011 05:53 AM
Double check the URL
09-20-2011 06:13 AM
The structure of module A who is a library like this:
is there something wrong?