Java Path Copy nio copy(Path inPath, Path outPath)

Here you can find the source of copy(Path inPath, Path outPath)

Description

copy

License

Open Source License

Declaration

public static void copy(Path inPath, Path outPath) throws IOException 

Method Source Code

//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();
        }
    }
}

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 from, Path to)
  6. copy(Path source, Path destination)
  7. copy(Path source, Path destination)
  8. copy(Path source, Path target)
  9. copy(Path source, Path target, CopyOption... options)