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?
About Question enthuware.ocpjp.ii.v11.2.1805 :
Moderator: admin
-
- Posts: 6
- Joined: Mon Mar 24, 2014 5:35 pm
- Contact:
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.ii.v11.2.1805 :
Not exactly. That's what the point 2 in the explanation explains.
-
- Posts: 4
- Joined: Thu Jan 02, 2025 12:25 pm
- Contact:
Re: About Question enthuware.ocpjp.ii.v11.2.1805 :
Isn't these files same? or does move() method checks only if path objects are the same?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.
Who is online
Users browsing this forum: Bing [Bot] and 11 guests