Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29817
| From | Jan Burse <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | With new Path (Re: A "current directory" concept for Java...) |
| Date | 2014-08-23 10:48 +0200 |
| Organization | albasani.net |
| Message-ID | <lt9khn$dba$1@news.albasani.net> (permalink) |
| References | <slrnlvet48.fp3.avl@login.logic.tuwien.ac.at> <lt9jh1$bib$1@news.albasani.net> |
Jan Burse schrieb:
>
> The getCanonicalPath() method will usually resolve
> ../ and ./ parts in the str together with curdir.
Things are a little confusing under the hood of
java.io.File. Since they use a method named resolve
which does not resolve ../ and ./.
The same confusion is under the hood of java.nio.file.Path,
the method named resolve does also not resolve ../ and
./. Here you have to use the method normalize.
So the solution with path would be:
public class State {
private static String curdir;
public void chDir(String str) {
curdir = Paths.getPath(curdir).resolve(str).normalize();
}
}
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