Java BufferedReader Copy copyFile(String srcFileName, String destFileName)

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

Description

Copy a file to another position

License

Open Source License

Parameter

Parameter Description
srcFileName Source file name
destFileName Destination file name

Exception

Parameter Description
IOException IOException

Declaration

public static void copyFile(String srcFileName, String destFileName) throws IOException 

Method Source Code


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

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class Main {
    /**//from w ww  .j av  a  2  s .  com
     * Copy a file to another position
     * @param srcFileName Source file name
     * @param destFileName Destination file name
     * @throws IOException IOException
     */
    public static void copyFile(String srcFileName, String destFileName) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(srcFileName));
        BufferedWriter bw = new BufferedWriter(new FileWriter(destFileName));
        String line;
        while ((line = br.readLine()) != null) {
            bw.write(line);
            bw.newLine();
        }
        br.close();
        bw.close();
    }
}

Related

  1. copyFile(String orig, String dest)
  2. copyFile(String source, String dest)
  3. copyFile(String src, String dst)
  4. copyFile(String src, String dst)
  5. copyFile(String srcFile, String dstFile)
  6. copyFile2(String source, String out)
  7. copyFileContentsIntoAnotherFile(String inputFileName, PrintWriter Out)
  8. copyFileFromJar(File jarFile, File targetFile, String sourceFilePath)
  9. copyFileLinewise(File inputFile, File outputFile)