Java how to copy file

https://w‮al.ww‬utturi.com
Java how to copy file
/**
 * @author lautturi.com 
 * Java example: copy files in java
 */

import java.util.*;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

public class Lautturi {

	public static void main(String[] args) {

		var source = new File("hello/test.txt");
		var dest = new File("hello/test-bak.txt");

		try {
			Files.copy(source.toPath(), dest.toPath(), 
					StandardCopyOption.REPLACE_EXISTING);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
Created Time:2017-09-25 00:21:28  Author:lautturi