Java Path Copy nio copy(Path from, Path to)

Here you can find the source of copy(Path from, Path to)

Description

Copy source file into target file if the target file exists, then the target file is replaced.

License

Open Source License

Parameter

Parameter Description
from The source file.
to The target file.

Exception

Parameter Description
IOException an exception

Return

Return the path to the target file.

Declaration

public static Path copy(Path from, Path to) throws IOException 

Method Source Code

//package com.java2s;
/*//w w w . j ava2 s  . co  m
 * This file is part of the Raster Storage Archive (RSA).
 *
 * The RSA is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * The RSA 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * the RSA.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2013 CRCSI - Cooperative Research Centre for Spatial Information
 * http://www.crcsi.com.au/
 */

import java.io.IOException;

import java.nio.file.Files;
import java.nio.file.Path;

import java.nio.file.StandardCopyOption;

public class Main {
    /**
     * Copy source file into target file if the target file exists, 
     * then the target file is replaced.
     * @param from The source file.
     * @param to The target file.
     * @return Return the path to the target file.
     * @throws IOException
     */
    public static Path copy(Path from, Path to) throws IOException {
        return Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
    }
}

Related

  1. addCopyRight(Path p)
  2. copy(FileInputStream from, FileOutputStream to)
  3. copy(final File source, final File target)
  4. copy(final Path source, final Path destination, final CopyOption... options)
  5. copy(Path inPath, Path outPath)
  6. copy(Path source, Path destination)
  7. copy(Path source, Path destination)
  8. copy(Path source, Path target)