Try like this it will work
Here properties file or folder must be in root directory as
MainFolder
|
Com.test.loadresource.file.java
|
resources
|
Resource file name
Class file{
private static void loadConfiguration() {
bundle =
ResourceBundle.getBundle(
"resources/properties_file_name.properties",
Locale.ENGLISH);
}
public static String getValue(String param_s_key) {
if (param_s_key == null || param_s_key.trim().length() <= 0)
return null;
return bundle.getString(param_s_key.trim());
}
public static void main(String arg[]){
System.out.println(getValue("0001"));
}
}
Regards
Raghavendra.E
--------------------------
Programmer Analyst
StinGray Technologies PVT LTD.
ODC, GlobalCase Technologies Inc.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 16, 2005 11:49 AM
To: Struts Users Mailing List
Subject: Re: Is it Possible!
I believe if you try to access from main it is not possible to access the
file without giving the absolute path.
However, if you try to access it from a servlet you can use
getServletContext().getRealPath(
"/WEB-INF/classes/myMessegeResources.properties").
Regards,
Basudeb Acharya
Tata Consultancy Services Limited
Mailto: [EMAIL PROTECTED]
Website: http://www.tcs.com
"Shailesh Barde" <[EMAIL PROTECTED]>
11/16/2005 09:51 AM
Please respond to
"Struts Users Mailing List" <[email protected]>
To
[email protected]
cc
Subject
Is it Possible!
hi,
I want to access myMessegeResources.properties.However, if i try to access
it this way it throws an exception of FileNotFound.However if i give Disk
absolute path then it accesses that myMessegeResources.properties file.
How to access the relative file in WEB-INF
1)Doesn't Works:-Here i have tried various relative paths to WEB-INF but
not worked!
public class showFilevalues {
public static void main(String args[])throws Exception
{
FileReader fr=new FileReader
("/WEB-INF/classes/myMessegeResources.properties");
BufferedReader br=new BufferedReader(fr);
String s;
while((s=br.readLine())!= null){
System.out.println(s); }
fr.close();
}
}
This Works:-
public class showFilevalues {
public static void main(String args[])throws Exception
{
FileReader fr=new FileReader
("C:/eclipse/workspace/shail/myProjectcontext/WEB-INF/classes/myMessegeResou
rces.properties");
BufferedReader br=new BufferedReader(fr);
String s;
while((s=br.readLine())!= null){
System.out.println(s); }
fr.close();
}
}
Is it Possible to how to access the relative file?
Regards,
Shailesh
ForwardSourceID:NT0000FFFA
Notice: The information contained in this e-mail message and/or attachments
to it may contain confidential or privileged information. If you are not
the intended recipient, any dissemination, use, review, distribution,
printing or copying of the information contained in this e-mail message
and/or attachments to it are strictly prohibited. If you have received
this communication in error, please notify us by reply e-mail or telephone
and immediately and permanently delete the message and any attachments.
Thank you
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]