Java Copying and Moving Files using path

Java Copying and Moving Files using path


copyTo method to copy file to target location
• Options to replace existing file, copy file attributes...

moveTo method to move file to target location
• Option to replace existing file
• Option to require operation to be atomic

import static java.nio.file.StandardCopyOption.*;
Path source = Path.get("C:\\My Documents\\Stuff.odp");
Path target = Path.get("D:\\Backup\\MyStuff.odp");
source.copyTo(target);
source.copyTo(target, REPLACE_EXISTING, COPY_ATTRIBUTES);

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations