Guest User

Untitled

a guest
Jun 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileInputStream ;
  3. import java.io.FileOutputStream ;
  4. import java.nio.channels.FileChannel ;
  5. import java.io.IOException ;
  6.  
  7. import java.util.Scanner;
  8.  
  9.  
  10. public class File_Manager
  11. {
  12.     FileChannel in = null; // canal d'entrée
  13.     FileChannel out = null; // canal de sortie
  14.    
  15.     public boolean copy ( String adr_in, String adr_out, boolean del ) throws IOException // t'occupes pas du del
  16.     {
  17.         try {
  18.             in = new FileInputStream ( adr_in ).getChannel () ;
  19.             out = new FileOutputStream ( adr_out ).getChannel () ;
  20.             //File source = new File(name_in);
  21.        
  22.             in.transferTo(0, in.size(), out);
  23.             }
  24.         catch (Exception e)
  25.             {
  26.                 e.printStackTrace();
  27.             }
  28.         finally
  29.             {
  30.                 //if ( del )  // del source
  31.                 in.close () ;
  32.                 out.close () ;
  33.             }
  34.         return false;
  35.     }
  36.    
  37.     public static void main (String s [])
  38.     {
  39.         Scanner sc = new Scanner(System.in);
  40.         String name_in = sc.next () ;
  41.         String name_out = sc.next () ;
  42.         copy ("c:\\truc.txt", "c:\\succes.txt", false) ;
  43.     }
  44. }
Add Comment
Please, Sign In to add comment