Java FileInputStream Copy copyFile(String oldFile, String newFile)

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

Description

copy File

License

Apache License

Declaration

public static void copyFile(String oldFile, String newFile) throws Exception 

Method Source Code

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

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

import java.io.InputStream;

public class Main {

    public static void copyFile(String oldFile, String newFile) throws Exception {
        File file1 = new File(oldFile);
        int byteRead;
        FileOutputStream fs = new FileOutputStream(newFile);
        InputStream inputStream = new FileInputStream(file1);
        byte[] buffer = new byte[1024];
        while ((byteRead = inputStream.read(buffer)) != -1) {
            fs.write(buffer, 0, byteRead);
        }//  ww w. ja v  a 2  s .c o m
        fs.close();
        inputStream.close();
    }
}

Related

  1. copyFile(String fromFilePath, String toFilePath)
  2. copyFile(String inFile, String outFile)
  3. copyFile(String inFileName, String outFileName)
  4. copyFile(String input, String output)
  5. copyFile(String inputFile, String outputFile)
  6. copyFile(String oldPath, String newPath)
  7. copyFile(String oldPath, String newPath)
  8. copyFile(String oldPathFile, String newPathFile)
  9. copyFile(String original, String copy)