How do I access a file in the file system from within a JSF Connector?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Daniel_Breitner
Posted On:   Monday, November 10, 2008 07:06 AM



I thought about something like but it always sees c: as starting folder.



Does anyone know how to do this?



With kind regards

daniel

Re: How do I access a file in the file system from within a JSF Connector?

Posted By:   naveen_sisupalan  
Posted On:   Wednesday, November 19, 2008 06:49 PM

Try this:

YouClassName.class.getClassLoader().getResourceAsStream("YouFile.txt");

Re: How do I access a file in the file system from within a JSF Connector?

Posted By:   Robert_Lybarger  
Posted On:   Monday, November 10, 2008 07:33 PM

Since it is in WEB-INF/classes, then it's in the root of the classpath ... so you could load it as a Resource instead of trying to resolve the local filesystem. (And in this case, this is probably the preferred way.) Might look into Class.getResource("/test.xml") or perhaps Class.getResourceAsStream("/test.xml") depending on what return type you want. (Stream tends to have best overall utility, IME.)
About | Sitemap | Contact