Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
bitpanda
Posts: 17
Registered: ‎08-02-2010

how to load resources from another module

How to load resources from another module such as a library?

I knew the method Class.forName(ClassPath).getResourceAsStream(filename), but I can't successfully read the file using it.

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!

Please use plain text.
Trusted Contributor
KraKra
Posts: 222
Registered: ‎08-11-2010

Re: how to load resources from another module

Did you try the same code to load resource from your own module ? 

 

In my opinion, the problem is in wrong resources URL ...

Please use plain text.
Contributor
bitpanda
Posts: 17
Registered: ‎08-02-2010

Re: how to load resources from another module

Yes, i have. And it works.

But i can't load other module's txt files. 

 

 

Please use plain text.
Trusted Contributor
KraKra
Posts: 222
Registered: ‎08-11-2010

Re: how to load resources from another module

Double check the URL

Please use plain text.
Contributor
bitpanda
Posts: 17
Registered: ‎08-02-2010

Re: how to load resources from another module

The structure of module A who is a library like this:

 

is there something wrong? 

 

Please use plain text.