How about using the Class.getResourceAsStream() method?  Something like this
in the servlet class will print the contents of the file:

      Class c = getClass();
      BufferedReader br = new BufferedReader(new
InputStreamReader(c.getResourceAsStream("myfile.txt")));
      String line = null;
      try
      {
         while ((line = br.readLine()) != null)
         {
            System.out.println(line);
         }
         br.close();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }


----- Original Message -----
From: Rob Hazlewood <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, July 16, 2000 9:02 AM
Subject: URGENT: How do i find where the class file is stored?


> Hi all!
> I need a servlet to be able to find out its own location, so a settings
file
> in the same directory can be opened
>
> thanks, help would be greatly appreciated
> Rob
>
> ____________________________________________________________________
> Get free email and a permanent address at http://www.netaddress.com/?N=1
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to