uni

University stuff
git clone git://git.christosmarg.xyz/uni-assignments.git
Log | Files | Refs | README | LICENSE

CopyPaste.java (599B)


      1 import java.io.*;
      2 
      3 class CopyPaste {
      4 	public static void main(String args[]) {
      5 		FileInputStream fis;
      6 		FileOutputStream fos;
      7 		int c;
      8 
      9 		try {
     10 			fis = new FileInputStream(args[0]);
     11 			fos = new FileOutputStream(args[1]);
     12 
     13 			while ((c = fis.read()) != -1)
     14 				fos.write(c);
     15 			fis.close();
     16 			fos.close();
     17 		} catch (FileNotFoundException e) {
     18 			System.err.println("file not found");
     19 			return;
     20 		} catch (IOException e) {
     21 			System.err.println("IO Exception");
     22 			return;
     23 		} catch (ArrayIndexOutOfBoundsException e) {
     24 			System.err.println("usage: java CopyPaste src dst");
     25 			return;
     26 		}
     27 	}
     28 }