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
In Java 7 you can use Files.copy() and very important is: Do not forget to close the OutputStream after creating the new file.
Files.copy()
OutputStream os = new FileOutputStream(targetFile); Files.copy(Paths.get(sourceFile), os); os.close();