Java BufferedReader Copy copyFile(String src, String dst)

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

Description

Copy a text file

License

MIT License

Declaration

public static void copyFile(String src, String dst) throws Exception 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright ? 2012-2015 eBay Software Foundation
 *  This program is dual licensed under the MIT and Apache 2.0 licenses.
 *  Please see LICENSE for more information.
 *******************************************************************************/

import java.io.BufferedReader;

import java.io.FileOutputStream;
import java.io.FileReader;

import java.io.PrintWriter;

public class Main {
    /**//from ww w . ja v a2  s.  com
     * Copy a text file
     */
    public static void copyFile(String src, String dst) throws Exception {
        BufferedReader inFile = null;
        PrintWriter outFile = null;
        String line;

        // Read in & Write out
        try {
            inFile = new BufferedReader(new FileReader(src));
            outFile = new PrintWriter(new FileOutputStream(dst));

            while ((line = inFile.readLine()) != null)
                outFile.println(line);
        } finally {
            if (inFile != null)
                inFile.close();
            if (outFile != null)
                outFile.close();
        }

    }
}

Related

  1. copyFile(File source, File dest)
  2. copyFile(File src, File dst)
  3. copyFile(String orig, String dest)
  4. copyFile(String source, String dest)
  5. copyFile(String src, String dst)
  6. copyFile(String srcFile, String dstFile)
  7. copyFile(String srcFileName, String destFileName)
  8. copyFile2(String source, String out)
  9. copyFileContentsIntoAnotherFile(String inputFileName, PrintWriter Out)