1

I am trying to move files (in linux OS) by using java code this happen when trying to move single file. Issue which looks to me is i guess similar to java.nio.Files.move() - DirectoryNotEmptyException on OS X

If so how can we handle it . Shall it be done on linux level or java.

Files.move(src, dst, new CopyOption[] { StandardCopyOption.REPLACE_EXISTING });

in this src folder is present in projs/dd/output/TAR
and dest folder is config_files/billing/xml/workArea

the error which comes is even though destination there is no file present nor folder in target:

WARNING: FAILED_TO$Failed to get MHS user handler
java.nio.file.DirectoryNotEmptyException: 
config_files/billing/xml/workArea/GBF_2017030001_000007540_00001_0000000004
        at sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:491)
        at sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:262)
        at java.nio.file.Files.move(Files.java:1347)

what i could see is both folders are on different FileSystem

by running stat -c "%d" "${Folder}" on linux OS.

is this cause of exception

Community
  • 1
  • 1
Deepak Negi
  • 97
  • 3
  • 12
  • Possible duplicate of [Java: Using nio Files.copy to Move Directory](http://stackoverflow.com/questions/15137849/java-using-nio-files-copy-to-move-directory) – baao Apr 14 '17 at 09:26
  • 1
    You cannot move a whole directory like this, unless it can be accomplished by a simple rename. Copying the contents of a whole directory from one filesystem to another is not supported with a single `move` call... – john16384 Apr 14 '17 at 09:29
  • i will edit the question. as it is movinf single file only but Error is misleading – Deepak Negi Apr 14 '17 at 09:40
  • We used java nio Files.move to move folder and it only works when moving in same file-system or when empty. In our case the filesystems are separate. So what I did was to add catch the exception and do copy+delete instead. I used apache file utils because they already have recursive copy and delete. – Deepak Negi Apr 14 '17 at 10:05

0 Answers0