Reputation: 606
Today I read in one 1z0-809 (OCP Java 8) preparation book that the Files.move() can be applied to non-empty directories only if they're on the same drive and that the moving a non-empty directory across a drive will throw a NIO.2 DirectoryNotEmptyException. But moving an empty directory across a drive will not. Could somebody please tell me why?
Upvotes: 0
Views: 522
Reputation: 897
I would wager a guess that it has something to do with how a native "move" works.
A raw "move" is simply changing a file pointer under the hood, vs a moving to a new drive really involves a copy and a delete, each of which fail on their own for different reasons than an actual "move". The author probably wants you to perform each operation individually so you can handle said operations on their own when moving across drives.
Upvotes: 2