import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class FileCopy { // geprüfte exceptions public static void main(String[] args) throws FileNotFoundException, IOException { FileInputStream fis = null; FileOutputStream fos = null; // Exception-Handler für ungeprüfte exceptions try { fis = new FileInputStream(args[0]); fos = new FileOutputStream(args[1]); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Die Parameterliste beim Programmaufruf sollte sein:"); System.out.println("java FileCopy quelldatei zieldatei"); return; } catch (Exception e) { if ( !"0".equals(e.getMessage()) ) { System.out.println(e.getMessage()); }else { System.out.println("Ein unerwarteter Fehler trat auf!"); } return; } int c; c = fis.read(); while ( c != -1 ) { fos.write(c); c = fis.read(); } fis.close(); fos.close(); } }