Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29817
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail |
|---|---|
| From | Jan Burse <janburse@fastmail.fm> |
| Newsgroups | comp.lang.java.programmer |
| Subject | With new Path (Re: A "current directory" concept for Java...) |
| Date | Sat, 23 Aug 2014 10:48:55 +0200 |
| Organization | albasani.net |
| Lines | 23 |
| Message-ID | <lt9khn$dba$1@news.albasani.net> (permalink) |
| References | <slrnlvet48.fp3.avl@login.logic.tuwien.ac.at> <lt9jh1$bib$1@news.albasani.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-15; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.albasani.net I2WXS8ycDq8bNqC2p5fJmeTi1Ra8IzwxiMf5HPtagVYJfpwM/wdAw/gDJRYNuR53FeA0mSMfhW3az1v1UBBTCw== |
| NNTP-Posting-Date | Sat, 23 Aug 2014 08:48:55 +0000 (UTC) |
| Injection-Info | news.albasani.net; logging-data="QS+68KnpBd7pXJgK1WzxDC6sImtahie8ndJdwatNq4f/WGlBxjuzvfExaBpJccaPaSkVZum3eLJwjPGeFkCgfaeDXIP0yhi1VXyVW0rd/mZQnQlU6W6VpUlHTwrJHnXM"; mail-complaints-to="abuse@albasani.net" |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26.1 |
| In-Reply-To | <lt9jh1$bib$1@news.albasani.net> |
| Cancel-Lock | sha1:gZcPCFSLZ88DeQK8yqoB0hUbZgU= |
| Xref | csiph.com comp.lang.java.programmer:29817 |
Show key headers only | View raw
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