Java FileInputStream Copy copyFile(String source, String dest)

Here you can find the source of copyFile(String source, String dest)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(String source, String dest)
            throws IOException 

Method Source Code

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {
    public static void copyFile(String source, String dest)
            throws IOException {
        copyFile(new File(source), new File(dest));
    }/*w  w  w .j  a va 2 s  . c o  m*/

    public static void copyFile(File source, File dest) throws IOException {
        InputStream input = null;
        OutputStream output = null;
        try {
            input = new FileInputStream(source);
            output = new FileOutputStream(dest);
            byte[] buf = new byte[1024];
            int bytesRead;
            while ((bytesRead = input.read(buf)) > 0) {
                output.write(buf, 0, bytesRead);
            }
        } finally {
            if (input != null)
                input.close();
            if (output != null)
                output.close();
        }
    }
}

Related

  1. copyFile(String pathOld, String pathNew)
  2. copyFile(String pathOrig, String pathDst)
  3. copyFile(String quelle, String ziel)
  4. copyFile(String resourceFimeName, String targetFileName)
  5. copyFile(String s, String s1)
  6. copyFile(String source, String destination)
  7. copyFile(String source, String destination)
  8. copyFile(String source, String destination)
  9. copyFile(String source, String destination)