Here you can find the source of copyFile(Path source, Path target, boolean foreign, CopyOption... options)
Parameter | Description |
---|---|
source | The source file path |
target | The target file path |
foreign | When true create a copy on the remote fiel system |
options | Copy options |
Parameter | Description |
---|---|
IOException | an exception |
private static void copyFile(Path source, Path target, boolean foreign, CopyOption... options) throws IOException
//package com.java2s; /*//from ww w .ja va 2 s . c o m * Copyright (c) 2013-2017, Centre for Genomic Regulation (CRG). * Copyright (c) 2013-2017, Paolo Di Tommaso and the respective authors. * * This file is part of 'Nextflow'. * * Nextflow 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. * * Nextflow 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 Nextflow. If not, see <http://www.gnu.org/licenses/>. */ import java.io.IOException; import java.io.InputStream; import java.nio.file.CopyOption; import java.nio.file.Files; import java.nio.file.Path; public class Main { /** * Copy a file to a local or foreign file system * * @param source The source file path * @param target The target file path * @param foreign When {@code true} create a copy on the remote fiel system * @param options Copy options * @throws IOException */ private static void copyFile(Path source, Path target, boolean foreign, CopyOption... options) throws IOException { if (!foreign) { source.getFileSystem().provider().copy(source, target, options); return; } try (InputStream in = Files.newInputStream(source)) { Files.copy(in, target); } } }