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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
goblingift
Posts: 6
Joined: Mon Mar 24, 2014 5:35 pm
Contact:

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

Post 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?

admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Not exactly. That's what the point 2 in the explanation explains.

szylica
Posts: 4
Joined: Thu Jan 02, 2025 12:25 pm
Contact:

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

Post 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?

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests