import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class FileCopy {
public static void main(String[] args) {
String fileDirectory= "D:/jdk/src/java/io/copy.txt ";
File fromFile = new File(fileDirectory);
if(!fromFile.exists()) {
System.out.printf( "File to copy, %s, does not exist. ",fromFile.getAbsolutePath());
}
File toFile = createBackupFile(fromFile);
FileInputStream inFile = null;
FileOutputStream outFile = null;
try {
inFile = new FileInputStream(fromFile);
outFile = new FileOutputStream(toFile);
} catch(FileNotFoundException e) {
e.printStackTrace(System.err);
assert false;
}
FileChannel inChannel = inFile.getChannel();
FileChannel outChannel = outFile.getChannel();
try {
int bytesWritten = 0;
long byteCount = inChannel.size();
while(bytesWritten