Java FileInputStream Copy copyFileAndReName(String destPath, String srcPath, String srcFile, String destFile)

Here you can find the source of copyFileAndReName(String destPath, String srcPath, String srcFile, String destFile)

Description

copy File And Re Name

License

Open Source License

Declaration

public static void copyFileAndReName(String destPath, String srcPath, String srcFile, String destFile)
            throws IOException 

Method Source Code


//package com.java2s;
import java.io.File;
import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

public class Main {
    public static void copyFileAndReName(String destPath, String srcPath, String srcFile, String destFile)
            throws IOException {
        (new File(destPath)).mkdirs();
        File file = new File(srcPath + srcFile);
        if (file.exists()) {
            FileInputStream input = new FileInputStream(file);
            FileOutputStream output = new FileOutputStream(destPath + "/" + destFile);
            byte[] b = new byte[1024 * 5];
            int len;
            while ((len = input.read(b)) != -1) {
                output.write(b, 0, len);
            }/*  w  ww.  ja va 2s. c  o m*/
            output.flush();
            output.close();
            input.close();
        }
    }
}

Related

  1. copyFile(String srFile, String dtFile)
  2. copyFile(String srFile, String dtFile)
  3. copyFile(String srFile, String dtFile)
  4. copyFile(String srFilePath, String dtFilePath)
  5. copyFile(String target, String source)
  6. copyFileAsStream(String srcFilePathName, String dstFilePathName)
  7. copyFileBin(File sourceFile, File targetFile)
  8. copyFileBinary(String source, String destination)
  9. copyFileContents(File fromFile, File destination, boolean useTempFilenames)