Java tutorial
//package com.java2s; /** * Title: efa - elektronisches Fahrtenbuch fr Ruderer * Copyright: Copyright (c) 2001-2011 by Nicolas Michael * Website: http://efa.nmichael.de/ * License: GNU General Public License v2 * * @author Nicolas Michael * @version 2 */ import java.io.*; public class Main { public static boolean copyFile(String quelle, String ziel) { if ((new File(quelle)).equals(new File(ziel))) { return false; // Quelle und Ziel sind dieselbe Datei! } final int BUFSIZE = 4096; FileInputStream f1; FileOutputStream f2; byte[] buf = new byte[BUFSIZE]; int n; if (!canOpenFile(quelle)) { return false; } try { f1 = new FileInputStream(quelle); f2 = new FileOutputStream(ziel); while ((n = f1.read(buf, 0, BUFSIZE)) > 0) { f2.write(buf, 0, n); } f1.close(); f2.close(); } catch (IOException e) { return false; } return true; } public static boolean canOpenFile(String d) { FileReader f; try { f = new FileReader(d); f.close(); } catch (Exception e) { return false; } return true; } }