Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileInputStream ;
- import java.io.FileOutputStream ;
- import java.nio.channels.FileChannel ;
- import java.io.IOException ;
- import java.util.Scanner;
- public class File_Manager
- {
- FileChannel in = null; // canal d'entrée
- FileChannel out = null; // canal de sortie
- public boolean copy ( String adr_in, String adr_out, boolean del ) throws IOException // t'occupes pas du del
- {
- try {
- in = new FileInputStream ( adr_in ).getChannel () ;
- out = new FileOutputStream ( adr_out ).getChannel () ;
- //File source = new File(name_in);
- in.transferTo(0, in.size(), out);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- finally
- {
- //if ( del ) // del source
- in.close () ;
- out.close () ;
- }
- return false;
- }
- public static void main (String s [])
- {
- Scanner sc = new Scanner(System.in);
- String name_in = sc.next () ;
- String name_out = sc.next () ;
- copy ("c:\\truc.txt", "c:\\succes.txt", false) ;
- }
- }
Add Comment
Please, Sign In to add comment