| Author |
How to Lookup an External File in Java Class
|
Md Ibrahim
Greenhorn
Joined: Mar 24, 2010
Posts: 14
|
|
Hi all,
How to lookup an external file say (.txt, .wav etc) with in java code, basically using file handling system.
Instead of hardcoding the direct system drive path (specific to just host),
how can we make this work anywhere by just deploying WAR file.
File aFile = new File ("D:\Test\MyFirst.txt");
How to lookup such files. Please do reply if any one has answer.
This File lookup is applicable both in servlet class and in normal Java backend class.
By,
Ibrahim
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
|
Can you set a system property? This can be set either on the server (for the .war) or by passing it to the java command (for the standalone program.)
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Md Ibrahim
Greenhorn
Joined: Mar 24, 2010
Posts: 14
|
|
hi jeanne,
Can you be a bit elaborate on explaining what and how to set system property.?
as far as i know, for servlet we can define context-param and use it in servlet
by getServletContext().getResource("NameGiven"); but how abt in Java class
also even the context lookup fails sometimes..
exactly where should i place my .txt File and where to put entry and how to make a lookup,so that
the file though resides on some remote server,is accessible by any client code.
By
Ibrahim
|
 |
 |
|
|
subject: How to Lookup an External File in Java Class
|
|
|