Hi again
I have that working fine now.. but how do i output to the file??
I've tried several things to try and determine the location of the file, but i
still can't find anything. can you help??
"Doug Turner" <[EMAIL PROTECTED]> wrote:
> The snippet of code works with JSWDK 1.0.1, it opens up the file if it is
> stored in the same directory as the class file for the Java class
executing.
> This directory does not include any Java distribution stuff like the jre,
> but it is in the classpath. This was tested from a servlet. YMMV.
>
> ----- Original Message -----
> From: Rob Hazlewood <[EMAIL PROTECTED]>
> To: Doug Turner <[EMAIL PROTECTED]>
> Sent: Sunday, July 16, 2000 3:33 PM
> Subject: Re: [Re: URGENT: How do i find where the class file is stored?]
>
>
> Doug,
> I don't think that will work
> it probably opens up a file in relation to where the jre is.
> with apache jserv (don't know about the rest), i have to give the full path
> /web/web/servlet/etc/settings.txt
> the location of the servlet is variable (the servlet is part of a package),
> so
> i need to be able to determine where the servlet is stored
> ie /web/web/servlet/
>
> basically a method that will tell me that servlet.class is stored in
> /web/...
>
> sorry, i'm very poor at explaining things!
> thanks for your time!
> Rob
>
> Doug Turner <[EMAIL PROTECTED]> wrote:
> > 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
>
>
> ____________________________________________________________________
> Get free email and a permanent address at http://www.netaddress.com/?N=1
>
____________________________________________________________________
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