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" <user@struts.apache.org>


To
user@struts.apache.org
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/myMessegeResources.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

Reply via email to