Java FileInputStream Copy copyFile(String src, String dest)

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

Description

copy File

License

Apache License

Declaration

public static void copyFile(String src, String dest) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

import java.io.InputStream;

public class Main {
    public static void copyFile(String src, String dest) {
        InputStream is = null;//from   w ww  .ja  v  a2  s  . co  m
        FileOutputStream fos = null;

        try {
            is = new FileInputStream(src);
            fos = new FileOutputStream(dest);
            int c = 0;
            byte[] array = new byte[1024];
            while ((c = is.read(array)) >= 0) {
                fos.write(array, 0, c);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                fos.close();
                is.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. copyFile(String src, File dest)
  2. copyFile(String src, String dest)
  3. copyFile(String src, String dest)
  4. copyFile(String src, String dest)
  5. copyFile(String src, String dest)
  6. copyFile(String src, String dst)
  7. copyFile(String src, String dst)
  8. copyFile(String src, String tar)
  9. copyFile(String src, String to)