Here you can find the source of copy(Path inPath, Path outPath)
public static void copy(Path inPath, Path outPath) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 SAP AG//from w w w .j ava 2s . com * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Apache License v2.0 which accompanies this distribution. * The Eclipse Public License is available at * http://www.eclipse.org/legal/epl-v10.html * and the Apache License v2.0 is available at * http://www.opensource.org/licenses/apache2.0.php. * You may elect to redistribute this code under either of these licenses. * * Contributors: * Violeta Georgieva - initial contribution *******************************************************************************/ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void copy(Path inPath, Path outPath) throws IOException { try (BufferedReader in = Files.newBufferedReader(inPath, StandardCharsets.UTF_8); BufferedWriter out = Files.newBufferedWriter(outPath, StandardCharsets.UTF_8);) { String line = null; while ((line = in.readLine()) != null) { out.write(line); } out.flush(); } } }