Java FileInputStream Copy copyFile(String inputFile, String outputFile)

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

Description

copy File

License

Open Source License

Declaration

public static void copyFile(String inputFile, String outputFile)
        throws FileNotFoundException 

Method Source Code

//package com.java2s;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {

    public static void copyFile(String inputFile, String outputFile)
            throws FileNotFoundException {
        File sFile = new File(inputFile);
        File tFile = new File(outputFile);
        FileInputStream fis = new FileInputStream(sFile);
        FileOutputStream fos = new FileOutputStream(tFile);
        int temp = 0;
        try {//from  ww w.  j a va  2 s .c  om
            while ((temp = fis.read()) != -1) {
                fos.write(temp);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fis.close();
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. copyFile(String fromFile, String toFile)
  2. copyFile(String fromFilePath, String toFilePath)
  3. copyFile(String inFile, String outFile)
  4. copyFile(String inFileName, String outFileName)
  5. copyFile(String input, String output)
  6. copyFile(String oldFile, String newFile)
  7. copyFile(String oldPath, String newPath)
  8. copyFile(String oldPath, String newPath)
  9. copyFile(String oldPathFile, String newPathFile)