import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; class copy_c // Hållare för mainfunktion { public static void main(String[] args) { if ( args.length != 2 ) { System.out.println( "Kör: javac källfil målfil" ); return; ////////// } // if try { File src_file = new File(args[0]); File dest_file = new File(args[1]); FileInputStream src_stream = new FileInputStream(src_file); FileOutputStream dest_stream = new FileOutputStream(dest_file); int c; while ((c = src_stream.read()) != -1) { dest_stream.write(c); } // src_stream.close(); dest_stream.close(); } // try catch (FileNotFoundException e) { System.err.println( "file not found:" + args[0]); } catch (IOException e) { System.err.println( "I/O error:" + e.getMessage()); } } // main } // copy_c