Here you can find the source of copy(Path from, Path to)
Parameter | Description |
---|---|
from | The source file. |
to | The target file. |
Parameter | Description |
---|---|
IOException | an exception |
public static Path copy(Path from, Path to) throws IOException
//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); } }