Java FileInputStream Copy copyFile(File from, File to)

Here you can find the source of copyFile(File from, File to)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(File from, File to) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

import java.util.Scanner;

public class Main {
    public static void copyFile(File from, File to) {
        try {/*ww  w  . j a  v  a  2 s.  c om*/
            Scanner fromScanner = new Scanner(new FileInputStream(from));
            PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(to)));

            while (fromScanner.hasNextByte()) {
                out.print(fromScanner.nextByte());
            }

            out.close();
            fromScanner.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. copyFile(File from, File to)
  2. copyFile(File from, File to)
  3. copyFile(File from, File to)
  4. copyFile(File from, File to)
  5. copyFile(File from, File to)
  6. copyFile(File from, File to)
  7. copyFile(File from, File to)
  8. copyFile(File from, File to, byte[] buf)
  9. copyFile(File from, File toDir)