Page 1 of 1

About Question enthuware.ocpjp.ii.v11.2.1805 :

Posted: Thu May 13, 2021 4:58 am
by goblingift
Isn´t there the StandardCopyOption.REPLACE_EXISTING missing in this line:
Files.move(p1, p2, StandardCopyOption.ATOMIC_MOVE);

Because with the current code, p2 already exists and will always throw an exception, right?

Re: About Question enthuware.ocpjp.ii.v11.2.1805 :

Posted: Fri May 14, 2021 10:33 am
by admin
Not exactly. That's what the point 2 in the explanation explains.

Re: About Question enthuware.ocpjp.ii.v11.2.1805 :

Posted: Sun Jan 12, 2025 6:04 am
by szylica
1. By default, Files.move method attempts to move the file to the target file, failing if the target file exists except if the source and target are the same file, in which case this method has no effect. Therefore, this code should throw an exception because a.java exists in the target directory.
Isn't these files same? or does move() method checks only if path objects are the same?