admin wrote:Can you try the following code on windows and tell me what inferences can you draw from the output?
Path p = Paths.get("\\temp");
System.out.println(p.toAbsolutePath());
p = Paths.get("/temp");
System.out.println(p.toAbsolutePath());
p = Paths.get("c:\\temp");
System.out.println(p.toAbsolutePath());
(Assuming that you are running the program from any directory in c:\)
-Paul.
Paul,
Thanks for your response. I'm afraid I won't be able to run those on Windows as I've used only Linux OS for a number of years.
I did attempt to run these on a Windows simulator through a browser as I do not wish to install a virtual machine on my Linux system.
I believe I have run similar cases in my 3rd to last post. If I'm not asking you much, would you please tell me what they are?
This is what's given by Oracle about toAbsolutePath() method.
Path toAbsolutePath()
Returns a Path object representing the absolute path of this path.
If this path is already absolute then this method simply returns this path. Otherwise, this method resolves the path in an implementation dependent manner, typically by resolving the path against a file system default directory. Depending on the implementation, this method may throw an I/O error if the file system is not accessible.
Returns:
a Path object representing the absolute path
The following are my educated guess:
For
p = Paths.get("c:\\temp");
System.out.println(p.toAbsolutePath());
I think it will print something like c:\temp in Windows as anything that starts with c: (or any letter followed by a colon) in Windows is an absolute path.
For
p = Paths.get("/temp");
System.out.println(p.toAbsolutePath());
Anything that starts with / in Linux indicates that it's an absolute path. This one? I'm not too sure in Windows.
For
Path p = Paths.get("\\temp");
System.out.println(p.toAbsolutePath());
I think it will print something like c:\temp in Windows as c: is the default directory in Windows.
This is all I have for you, Paul.
Paul, I asked you something and you ask me to answer these questions. I'm sure there must be a reason you wanted me to answer these questions.
When you make a few comment(s) in response to what I've written here, would you mind kindly tie your reasoning behind asking me to answer these questions to the question in my original post? Many thanks, Paul.
Schmichael