Skip to content
Snippets Groups Projects
Commit 5dec5d4e authored by Daniel Meißner's avatar Daniel Meißner
Browse files

Added lesson 4 exercise 1

parent a892ca01
No related branches found
No related tags found
No related merge requests found
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();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment