Java File Copy fileCopy(String from, String to)

Here you can find the source of fileCopy(String from, String to)

Description

Copy a file.

License

Open Source License

Parameter

Parameter Description
from filename to copy from
to filename to copy to

Declaration

static public void fileCopy(String from, String to) throws IOException 

Method Source Code

//package com.java2s;
/**/*from   ww w.  ja  va 2s.  c o m*/
 * Util.java
 * @author John Green
 * 27-Oct-2002
 * www.joanju.com
 * 
 * Copyright (c) 2002 Joanju Limited.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 */

import java.io.*;

public class Main {
    /** Copy a file.
     * @param from filename to copy from
     * @param to filename to copy to
     */
    static public void fileCopy(String from, String to) throws IOException {
        fileThing(from, to, false);
    }

    static private void fileThing(String from, String to, boolean append) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader(from));
        BufferedWriter out = new BufferedWriter(new FileWriter(to, append));
        int c;
        while ((c = in.read()) != -1)
            out.write(c);
        in.close();
        out.close();
    }
}

Related

  1. doCopyFile(File srcFile, File destFile, boolean preserveFileDate)
  2. doCopyFile(File srcFile, File destFile, boolean preserveFileDate)
  3. fileCopy(File source, String dest)
  4. fileCopy(File srcFile, File tarFile)
  5. FileCopy(InputStream input, OutputStream output, int bufferSize)
  6. fileCopy(String from, String to)
  7. fileCopy(String fromPath, String toPath)
  8. fileCopy(String oldFilePath, String newFilePath, boolean isCover)
  9. fileCopy(String sFrom, String sTo)