Skip to content

Instantly share code, notes, and snippets.

@3c7
Last active August 29, 2015 14:19
Show Gist options
  • Save 3c7/6ce476739ecbb1d51c69 to your computer and use it in GitHub Desktop.
Save 3c7/6ce476739ecbb1d51c69 to your computer and use it in GitHub Desktop.
Datenstrukturen und Algorithmen - Übungsblatt 3 - Aufgabe 5 (kein Praktomat upload notwendig)
import java.io.*;
public class FileCopy {
public static void main(String[] args) throws IOException {
try {
FileInputStream fis = new FileInputStream(args[0]);
FileOutputStream fos = new FileOutputStream(args[1]);
int c;
c = fis.read();
while (c != -1) {
fos.write(c);
c = fis.read();
}
fis.close();
fos.close();
} catch (ArrayIndexOutOfBoundsException aioobe) {
System.out.println("Bitte zwei Dateien angeben.");
} catch (IOException ioe) {
System.out.println("Datei nicht gefunden.");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment