exception - Copying a directory in Java -


basically reading this tutorial, have come across bit in explains how use replace_existing standardcopyoption.

replace_existing – performs copy when target file exists. if target symbolic link, link copied (and not target of link). if target non-empty directory, copy fails filealreadyexistsexception exception.

at end of bit quoted, says "if target non-empty directory, copy fails filealreadyexistsexception exception." have tried , not give me exception, tried copy non-empty folder location desktop , succeeded without giving me filealreadyexistsexception in theory should have got.

is regular?

try one:

create:

c:\map1\filea.txt c:\map2\fileb.txt 

move:

c:\map1 c:\map2 files.copy(         (new file("c:\map1")).topath(),          (new file("c:\map2")).topath(),          standardcopyoption.replace_existing); 

this results in:

c:\map1\filea.txt c:\map2\fileb.txt 

why?:

"directories can copied. however, files inside directory not copied, new directory empty when original directory contains files."

as mentioned reference.

directorynotemptyexception - replace_existing option specified file cannot replaced because non-empty directory (optional specific exception)

filealreadyexistsexception - if target file exists cannot replaced because replace_existing option not specified (optional specific exception)

source.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -