FileTransfer.java
Dosyayı İndir
package com.godoro.nio.channel;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
public class FileTransfer {
public static void main(String[] args)throws Exception {
String source="source.txt";
String target="target.txt";
RandomAccessFile from = new RandomAccessFile(source, "r");
FileChannel in = from.getChannel();
RandomAccessFile to = new RandomAccessFile(target, "rw");
FileChannel out = to.getChannel();
long start=0;
long count = in.size();
//out.transferFrom(in,start, count);
in.transferTo(start, count, out);
System.out.println("İçerik aktarımı tümlendi.");
}
}
Dosyayı İndir