• Post Reply Bookmark Topic Watch Topic
  • New Topic

Paths isSameFile  RSS feed

 
Florian Jedamzik
Ranch Hand
Posts: 46
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi;)

I am currently preparing for the OCP Exam and I tried out following
Examples in Eclipse (I also have a Windows machine):




It prints out "true" twice. It is an Example from the OCP study guide from page 472, where I added the normalize() Methode.

This is the original Example from page 472:





Here I get a NoSuchFileException, though I say on page 473: "...the symbol .. cancels out
the tree path of the path, relsuting in the Method ... outputting true.

Why does it cancel out the tree path (child)? I thought only normalize() would do that?

I hope everyone can understand what I'm talking about;)

Kind regards
Florian
 
Henry Wong
author
Sheriff
Posts: 22852
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Florian Jedamzik wrote:
Here I get a NoSuchFileException, though I say on page 473: "...the symbol .. cancels out
the tree path of the path, relsuting in the Method ... outputting true.

Why does it cancel out the tree path (child)? I thought only normalize() would do that?


First, the second result doesn't say that the files are different. The result is saying that the files (or one of them), does not exist.  As for why the normalize() method returned true, take a look at the documentation for the answer... The documentation clearly says that the method does not actually look at the file, and will "normalize" the path based on the rules of the file system. Unfortunately, there are certain features such as mount points and symbolic links that make it impossible to "normalize" the path without looking at the directories and files.

So, what is happening is... the normalize() method is incorrectly doing it's job, returning files, which are then deemed equal. I recommend traversing the directories and path manually to see if you are using symbolic links and/or going through mount points.

Henry
 
Florian Jedamzik
Ranch Hand
Posts: 46
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see;)

Thank you Henry!;)

Kind regards
Florian
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!