Android File Copy copyFile(String srcFile, String destFile)

Here you can find the source of copyFile(String srcFile, String destFile)

Description

copies a file to a new location on the local file system.

License

Open Source License

Parameter

Parameter Description
srcFile a parameter
destFile a parameter

Declaration

public static Boolean copyFile(String srcFile, String destFile) 

Method Source Code

//package com.java2s;
/*/*from w  ww.j a va  2 s.c o  m*/
 *  Copyright (C) 2010-2012 Stichting Akvo (Akvo Foundation)
 *
 *  This file is part of Akvo FLOW.
 *
 *  Akvo FLOW is free software: you can redistribute it and modify it under the terms of
 *  the GNU Affero General Public License (AGPL) as published by the Free Software Foundation,
 *  either version 3 of the License or any later version.
 *
 *  Akvo FLOW is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *  See the GNU Affero General Public License included below for more details.
 *
 *  The full license text can also be seen at <http://www.gnu.org/licenses/agpl.html>.
 */

import java.io.File;

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

public class Main {
    /**
     * copies a file to a new location on the local file system. This implementation will not create
     * any directories (so the destination directory must exist).
     * 
     * @param srcFile
     * @param destFile
     * @return
     */
    public static Boolean copyFile(String srcFile, String destFile) {
        Boolean copyFlag = false;
        File inputFile = new File(srcFile);
        File outputFile = new File(destFile);
        try {
            FileReader in = new FileReader(inputFile);
            FileWriter out = new FileWriter(outputFile);
            int c;

            while ((c = in.read()) != -1)
                out.write(c);

            in.close();
            out.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return copyFlag;
    }
}

Related

  1. copyFile(String oldPath, String newPath)
  2. copyFile(String origPath, String destPath)
  3. copyFile(String sourceFileName, String destinationFileName)
  4. copyFile(String sourcePath, String destPath)
  5. copyFile(String sourcePathName, String destPathName)
  6. copyFile(String strSrc, String strDest)
  7. copyFileByCommand(String src, String dst, boolean isMove)
  8. copyFileLazy(String source, String destination)
  9. copyFileToFile(File file, File outFile)