I have two Java.io.File objects file1 and file2. I want to copy the contents from file1 to file2. Is there an standard way to do this without me having to create a method th
Since Java 7 you can use Files.copy() from Java's standard library.
You can create a wrapper method:
public static void copy(String sourcePath, String destinationPath) throws IOException {
Files.copy(Paths.get(sourcePath), new FileOutputStream(destinationPath));
}
that can be used in the following way:
copy("source.txt", "dest.txt");