The recommended approach is just to use a relative path. If you need an
absolute path for some reason and you can't use File.getAbsolutePath(), then
either ServletContext.getRealPath() or System.getProperty("user.dir") should
be fine.
I definitely wouldn't trim the last character without checking it against
File.separator, though.
Glad you got it working,
Don
On Wed, Mar 24, 2010 at 11:12 AM, Steve Pritchard <[email protected]>wrote:
> WORKING. Thanks.
>
> As an education what is the recommended way to find the base file
> location.
>
> Thanks for the help.
> Steve
>
> On Mar 24, 12:07 pm, Steve Pritchard <[email protected]> wrote:
> > Oops, the last digit is missing. Always before there was a trailing
> > "/". It is now gone. Let me fix my code and only trim the "/" if it
> > is there.
> > Conclusion: Something changed (the last "/") but I can fix it.
> > Thanks, Steve
> >
> > On Mar 24, 12:01 pm, Steve Pritchard <[email protected]> wrote:
> >
> > > Sorry my bad, its looking at ServerContext. However, it and user.dir
> > > are the same.
> >
> > > oCfg --> ServletConfig
> > > sFilePath = oCfg.getServletContext().getRealPath("/");
> > > results in after adding the filename stuff.
> > > /base/data/home/apps/gems-bbb/1.34076359212150974/app-bbb/bbb.ace
> >
> > > From log in same run,
> > > sWebAppLocn = System.getProperty("user.dir").substring(1);
> > > WebAppLocn: base/data/home/apps/gems-bbb/1.340763592121509746 (from
> > > user.dir)
> >
> > > On Mar 24, 11:31 am, Don Schwarz <[email protected]> wrote:
> >
> > > > Can you paste the code that looks at user.dir? That file path is not
> > > > correct (the version number is wrong), but I can't tell if it has
> changed
> > > > since you generated this error or if there is something else going
> on.
> >
> > > > On Wed, Mar 24, 2010 at 10:28 AM, Steve Pritchard <
> [email protected]>wrote:
> >
> > > > > Reading the system properties file, namely user.dir
> >
> > > > > Further investigation says the first statement to create
> > > > > BufferedReader is open is failing - the method is returning a null.
> > > > > Steve
> >
> > > > > On Mar 24, 11:19 am, Don Schwarz <[email protected]> wrote:
> > > > > > How are you generating that file path?
> >
> > > > > > On Wed, Mar 24, 2010 at 10:05 AM, Steve Pritchard <
> [email protected]
> > > > > >wrote:
> >
> > > > > > > My applications read an initialization file to prime
> themselves.
> >
> > > > > > > Overnight they both broke. The code
> >
> > > > > > > public static String[] loadFileAsStrings(String sFileName) {
> > > > > > > try {
> > > > > > > BufferedReader oR = new BufferedReader(new
> > > > > > > FileReader(sFileName));
> > > > > > > ArrayList<String> oLst = new ArrayList();
> > > > > > > while (true) {
> > > > > > > String sL = oR.readLine();
> > > > > > > if (sL == null) break;
> > > > > > > oLst.add(sL);
> > > > > > > }
> > > > > > > oR.close();
> > > > > > > String[] oXs = (String[])oLst.toArray(new
> String[oLst.size()]);
> > > > > > > return oXs;
> > > > > > > } catch (Exception e) {
> > > > > > > return null;
> > > > > > > }
> > > > > > > }
> >
> > > > > > > does not return the file. It did previously.
> >
> > > > > > > reading file
> /base/data/home/apps/gems-bbb/1.34076326484386876/web-
> > > > > > > gems/core.ace
> > > > > > > nolonger works. It did yesterday and I changed nothing.
> Redeploying
> > > > > > > does not fix the problem.
> >
> > > > > > > It looks like the core.ace file is not there. How do I check?
> >
> > > > > > > Thanks,
> > > > > > > Steve
> >
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the
> Google
> > > > > Groups
> > > > > > > "Google App Engine for Java" group.
> > > > > > > To post to this group, send email to
> > > > > > > [email protected].
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > [email protected]<google-appengine-java%[email protected]>
> <google-appengine-java%[email protected]<google-appengine-java%[email protected]>
> >
> > > > > <google-appengine-java%[email protected]<google-appengine-java%[email protected]>
> <google-appengine-java%[email protected]<google-appengine-java%[email protected]>
> >
> >
> > > > > > > .
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/google-appengine-java?hl=en.
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> Groups
> > > > > "Google App Engine for Java" group.
> > > > > To post to this group, send email to
> > > > > [email protected].
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]<google-appengine-java%[email protected]>
> <google-appengine-java%[email protected]<google-appengine-java%[email protected]>
> >
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.