has root. The root under linux is / and for windows is c:\Paths.get("\\index.html");
About Question enthuware.ocpjp.v7.2.1599 :
Moderator: admin
-
- Posts: 17
- Joined: Fri Oct 11, 2013 10:31 am
- Contact:
About Question enthuware.ocpjp.v7.2.1599 :
How come
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1599 :
It considers a path starting with \\ as root as well. Although they haven't specified an exact definition of a root anywhere.
You may want to try it out.
-Paul.
You may want to try it out.
-Paul.
-
- Posts: 1
- Joined: Sat Jun 20, 2015 11:42 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1599 :
I'm don't understand why Explanation is saying that "if a path starts with a // or c:" has a root, but example is with "\\"
Paths.get("\\index.html");
It doesn't matter if it's starting with "\\" or "//", that's always a root?
Thanks
Paths.get("\\index.html");
It doesn't matter if it's starting with "\\" or "//", that's always a root?
Thanks
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1599 :
Well, On *nix systems, path separator is /, a path starting with \ is not root.
-
- Posts: 2
- Joined: Sat Oct 31, 2015 4:19 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1599 :
Prints the following on my linux box:
../\index.html
../\index.html
-
- Posts: 17
- Joined: Wed Jan 07, 2015 12:06 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1599 :
To run the code in linux, you need to create the path object like this
because the root in Linux is "/"...
I want to know in the real exam, do they specified which OS they using? If not , it seems like ambiguous about the separator...
Code: Select all
Path p1 = Paths.get("photos/goa");
Path p2 = Paths.get("/index.html");
I want to know in the real exam, do they specified which OS they using? If not , it seems like ambiguous about the separator...
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1599 :
In the exam, you can assume that if the separater is /, then the code is for linux and if it is \\, then the code is for windows.
HTH,
Paul.
HTH,
Paul.
-
- Posts: 97
- Joined: Wed Dec 28, 2016 9:00 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1599 :
So on nix systems I am assuming "/" has to escaped to "//" hence the code in question also causes error? Am I right?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1599 :
No, on a *nix based system, you do not need to escape /.
Who is online
Users browsing this forum: No registered users and 7 guests