Java FileInputStream Copy copyFile(File of, File nf)

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

Description

copy File

License

Open Source License

Declaration

public static boolean copyFile(File of, File nf) 

Method Source Code

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

import java.io.*;

public class Main {
    public static boolean copyFile(File of, File nf) {
        InputStream in;//from   ww w  .ja  v a 2s .  com
        try {
            in = new FileInputStream(of);
            OutputStream out = new FileOutputStream(nf);
            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) > 0) {
                out.write(buf, 0, len);
            }
            in.close();
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return false;
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
}

Related

  1. copyFile(File input, File output)
  2. copyFile(File inputFile, File outputFile)
  3. copyFile(File inputFile, File outputFile)
  4. copyFile(File inputFile, File outputFile)
  5. copyFile(File inputFile, OutputStream os)
  6. copyFile(File oldFile, File newFile)
  7. copyFile(File oldFile, String newPath)
  8. copyFile(File orig, File dest)
  9. copyFile(File orig, File dest, boolean overwrite)