Files.copy() under Linux at least will remove the existing destination even if the source cannot be read...
Francis Galiegue
fgaliegue at gmail.com
Wed Feb 11 20:57:23 UTC 2015
Not sure if this is wanted, but...
$ touch a b
$ ls -l ?
-rw-rw-r-- 1 fge fge 0 Feb 11 21:55 a
-rw-rw-r-- 1 fge fge 0 Feb 11 21:55 b
$ chmod 0 a
$ cp a b
cp: cannot open ‘a’ for reading: Permission denied
$ ls -l ?
---------- 1 fge fge 0 Feb 11 21:55 a
-rw-rw-r-- 1 fge fge 0 Feb 11 21:55 b
$
BUT...
If I have Paths to a and b and do:
Files.copy(a, b, StandardCopyOption.REPLACE_EXISTING);
then b is deleted even though you cannot even copy the contents from a
in the first place!
Honestly, I'd have expected it to behave like "cp" here...
--
Francis Galiegue, fgaliegue at gmail.com, https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa
More information about the nio-dev
mailing list