Java Path File Move mio move(Path from, Path to)

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

Description

Move 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 move(Path from, Path to) throws IOException 

Method Source Code

//package com.java2s;
/*//from   w w  w  . ja v a  2 s  . c  o  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 {
    /**
     * Move 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 move(Path from, Path to) throws IOException {
        return Files.move(from, to, StandardCopyOption.REPLACE_EXISTING);
    }
}

Related

  1. move(Path source, Path destination)
  2. moveDirectory(Path srcPath, Path destPath)
  3. moveFile(Path from, Path to)
  4. moveFile(Path source, Path target)