// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class CopyFile {
    public static void copy(String fromname, String toname) throws IOException {
        InputStream is = new FileInputStream(fromname);
        OutputStream os = new FileOutputStream(toname);
        byte[] b = new byte[100000];
        int n;
        while((n = is.read(b)) >= 0) {
            os.write(b, 0, n);        
        }
    }
    public static void main(String[] args) throws Exception {
        copy("C:\\test.exe", "C:\\temp\\test.exe");
    }
}
