Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29816
| From | Jan Burse <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: A "current directory" concept for Java... |
| Date | 2014-08-23 10:31 +0200 |
| Organization | albasani.net |
| Message-ID | <lt9jh1$bib$1@news.albasani.net> (permalink) |
| References | <slrnlvet48.fp3.avl@login.logic.tuwien.ac.at> |
Andreas Leitgeb schrieb:
> e.g.: the wrapped Path of curDir originally points to "/tmp", then...
> - curDir.chDir("foo") would go to "/tmp/foo", then
> - curDir.chDir("../bar") would go to "/tmp/bar", then
> - curDir.chDir("/foo") would go to "/foo"
if you use a static variable to hold the current
directory, it will be seen class loader wide.
Means for a standalone application you will
have one current directory, and for web applications
it could happen that each web context has its own
current directory.
public class State {
private static String curdir;
public void chDir(String str) {
curdir = new FIle(curdir,str).getCanonicalPath();
}
}
The getCanonicalPath() method will usually resolve
../ and ./ parts in the str together with curdir.
But I am not sure how binding the Java contract is.
I find in the comment only saying "typical":
"A canonical pathname is both absolute and unique.
The precise definition of canonical form is system-
dependent. This method first converts this pathname
to absolute form if necessary, as if by invoking the
{@link #getAbsolutePath} method, and then maps it to
its unique form in a system-dependent way. This
typically involves removing redundant names such as
<tt>"."</tt> and <tt>".."</tt> from the pathname,
resolving symbolic links (on UNIX platforms), and
converting drive letters to a standard case (on
Microsoft Windows platforms)."
Bye
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-22 16:49 +0000
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-22 14:50 -0400
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-22 15:10 -0400
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-22 19:26 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-22 23:38 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-23 14:24 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-23 16:31 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-23 19:34 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-24 08:42 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-24 10:37 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-24 13:41 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-24 18:33 +0000
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-24 22:33 +0000
Re: A "current directory" concept for Java... Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-25 00:14 +0000
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-22 19:45 -0400
Re: A "current directory" concept for Java... Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-23 15:32 +0000
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-23 12:49 -0400
Re: A "current directory" concept for Java... Jeff Higgins <jeff@invalid.invalid> - 2014-08-23 17:40 -0400
Re: A "current directory" concept for Java... Jan Burse <janburse@fastmail.fm> - 2014-08-23 10:31 +0200
With new Path (Re: A "current directory" concept for Java...) Jan Burse <janburse@fastmail.fm> - 2014-08-23 10:48 +0200
Re: With new Path (Re: A "current directory" concept for Java...) Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-23 14:38 +0000
Re: A "current directory" concept for Java... Roedy Green <see_website@mindprod.com.invalid> - 2014-08-23 05:31 -0700
csiph-web