Referencing a file path using -D and using it in getClass.getResourceAsStream()
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   neal_ravindran
Posted On:   Tuesday, May 17, 2005 07:13 AM

When I start my app I do this

java -Dmyapp.root=/usr/home/neal


a) Now when I reference "/usr/home/neal/someFile.txt" using getClass.getResourceAsStream(System.getProperty(myapp.root)+"/"+"someFile.txt") will the class look for the file from root of classloader or does it look in the actual physical dir path?



b)How can I make getClass.getResourceAsStream() see a file in the actual physical path on server?

Re: Referencing a file path using -D and using it in getClass.getResourceAsStream()

Posted By:   Anonymous  
Posted On:   Tuesday, May 17, 2005 07:20 AM

If you want a normal file from the filesystem, why not open it as a FileInputStream?


InputStream is = new FileInputStream(new File(System.getProperty("myapp.root"), "someFile.txt"));
About | Sitemap | Contact