cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in java.io.file reading

Former Member
0 Kudos

Hi

I have a servlet and it calls some classes which are kept in a jar file in WEB-INF/lib directory. With in one of the classes there is a IO file read happening. How should i read the file and what path should i put if the file is in WEB-INF/resources

my jar files are in web-inf/lib directory. How will i read the file and what should be the patch to be given

regards,

Sujesh

View Entire Topic
Former Member
0 Kudos

Hi,

Check this out

FileInputStream fis = new FileInputStream(new File("..
resources
filenmae"));

.. refers to parent directory ( in your case it is WEB-INF ).

Regards,

Uma

Former Member
0 Kudos

Thanks Uma..

The class reading the file in in some directory structure but lies in a jar file in lib directory

Former Member
0 Kudos

I have a servlet which calls a class. The class inturn reads an xml file which is kept inside web-inf, inside web-inf/lib, and the class's folder. Iam trying to read the file using

InputStream isStream = this.getClass().getClassLoader().getResourseAsStream("config.xml")

isStream is coming as null...how will i read it.I made ear file and deployed in was 6.4 sp11

Any suggestions??

Former Member
0 Kudos

Hi Sujesh,

Can you try the following method..

InputStream inp = this.getClass().getClassLoader().getResourceAsStream("com/package1/abc.xml");

Regards,

Ananth