<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>2.10.0</version>
</dependency>
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
public class FileCopyExample {
public static void main(String[] args) {
try {
File sourceFile = new File("path/to/source/file.txt");
File destinationFile = new File("path/to/destination/file.txt");
FileUtils.copyFile(sourceFile, destinationFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}