joseleonweb

Untitled

Feb 28th, 2021
746
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2.  
  3. public class CopyFile2 {
  4.     public static void main(String[] args) throws IOException
  5.     {
  6.         int i;
  7.        
  8.         // First, confirm that both files has been specified.
  9.         if(args.length != 2) {
  10.             System.out.println("Usage: CopyFile from to");
  11.             return;
  12.         }
  13.        
  14.         // Open and manage two files via the try statement.
  15.         try(FileInputStream fin = new FileInputStream(args[0]);
  16.             FileOutputStream fout = new FileOutputStream(args[1]))
  17.         {
  18.            
  19.             do {
  20.                 i = fin.read();            // Read bytes from one file
  21.                 if(i != -1) fout.write(i); // and write them to another
  22.             } while(i != -1);
  23.        
  24.         } catch(IOException exc) {
  25.             System.out.println("I/O Error: " + exc);
  26.         }
  27.     }
  28. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×