Basic usage question
Kasper Nielsen
kasperni at gmail.com
Fri Jul 30 06:58:32 PDT 2010
Thanks Alan,
I completely missed that paragraph in
http://download-llnw.oracle.com/javase/tutorial/essential/io/pathOps.html.
If possible you could add the syntax to
http://download-llnw.oracle.com/javase/tutorial/essential/io/legacy.html
new File(parent, "newfile") -> parent.resolve("newfile")
Cheers
Kasper
On 29/07/10 21.22, Alan Bateman wrote:
> Kasper Nielsen wrote:
>> Hi,
>>
>> I've been unable to answer this _very_ basic question.
>>
>> Considering the following code using the regular File class.
>>
>> File f = new File("/home/foo");
>> File fnew = new File(f, "tmp");
>>
>> How do I do this done using the Path class?
>>
>> Do I need to resort to using something like this?
>>
>> Path p=Paths.get("/home/foo");
>> Path ptmp=Paths.get(p.toString() + p.getFileSystem().getSeparator() +
>> "tmp")?
>>
>> Cheers
>> Kasper
> Are you looking for the resolve methods? For the above then
> Paths.get("/home/foo").resolve("tmp") will do it. The resolve methods
> are actually more functional than the 2-arg File constructor in that
> they know how to resolve all combinations of paths (important on
> platforms like Windows where there are at least 5 types of paths).
>
> -Alan.
>
More information about the nio-discuss
mailing list