About Question enthuware.ocpjp.v7.2.1603 :
Moderator: admin
-
- Posts: 8
- Joined: Wed Mar 16, 2016 10:57 am
- Contact:
About Question enthuware.ocpjp.v7.2.1603 :
Hi,
I understand everything about this question except one thing.
Where does "file:///" come from?
When I looked at the toUri() method in the java api it said:
"This method constructs an absolute URI with a scheme equal to the URI scheme that identifies the provider. The exact form of the scheme specific part is highly provider dependent."
So isn't it possible this won't start with "file:///"?
I understand everything about this question except one thing.
Where does "file:///" come from?
When I looked at the toUri() method in the java api it said:
"This method constructs an absolute URI with a scheme equal to the URI scheme that identifies the provider. The exact form of the scheme specific part is highly provider dependent."
So isn't it possible this won't start with "file:///"?
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1603 :
It is certainly possible that it won't start with file:///. But no other options are given so it is ok to assume that on this particular system it will start with file:/// (if there is no exception, of course).
HTH,
Paul.
HTH,
Paul.
-
- Posts: 25
- Joined: Thu Jun 01, 2017 2:50 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1603 :
Re the quote from the API “... an empty path is returned if this path does have a root component and all name elements are redundant" I tried this and do see the root e.g.
Path p1 = Paths.get("c:/x/../y/../z/..");
System.out.println(p1.normalize());
prints "c:" not "" (nothing).
Do you think this might be a typo in the API? Maybe it should read "... does not have a root component ...”?
Path p1 = Paths.get("c:/x/../y/../z/..");
System.out.println(p1.normalize());
prints "c:" not "" (nothing).
Do you think this might be a typo in the API? Maybe it should read "... does not have a root component ...”?
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1603 :
Can you please post the link where you saw this written?
-
- Posts: 25
- Joined: Thu Jun 01, 2017 2:50 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1603 :
The "Returns" section of the full method description in https://docs.oracle.com/javase/7/docs/a ... /Path.html
Same in the descriptive comment in the source code file as seen via NetBeans (Navigate > Go to Source)
(And then reproduced in the Explanation for this Enthuware Q)
Same in the descriptive comment in the source code file as seen via NetBeans (Navigate > Go to Source)
(And then reproduced in the Explanation for this Enthuware Q)
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1603 :
I see. Yes, it could be a typo.
-
- Posts: 25
- Joined: Thu Jun 01, 2017 2:50 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1603 :
Thanks - good to have an opinion from a much more knowledgable source 

-
- Posts: 3
- Joined: Sat Jan 04, 2025 6:45 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1603 :
for my env output is:
``````
```
Code: Select all
Defined import java.nio.file.Path
Defined import java.nio.file.Paths
Defined field Path p1 = c:\..\temp\test.txt
System.out.println(p1.normalize().toUri())
file:///usr/lib/jvm/java-21-openjdk-21.0.5.0.11-1.fc41.x86_64/bin/c:%5C..%5Ctemp%5Ctest.txt
Who is online
Users browsing this forum: No registered users and 10 guests