Java BufferedInputStream Copy copyFile(File file, File ziel)

Here you can find the source of copyFile(File file, File ziel)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(File file, File ziel) throws FileNotFoundException, IOException 

Method Source Code


//package com.java2s;
/*//from   w  ww .  j  a  v a2 s. c  o m
 * Copyright (C) 2012 Calenria <https://github.com/Calenria/> and contributors
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 3.0 of the License, or (at your option)
 * any later version.
 * 
 * This program 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 Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see
 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
 */

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    private static BufferedInputStream in = null;
    private static BufferedOutputStream out = null;

    public static void copyFile(File file, File ziel) throws FileNotFoundException, IOException {

        // System.out.println("Copy " + file.getAbsolutePath() + " to " +
        // ziel.getAbsolutePath());
        in = new BufferedInputStream(new FileInputStream(file));
        out = new BufferedOutputStream(new FileOutputStream(ziel, true));
        int bytes = 0;
        while ((bytes = in.read()) != -1) {
            out.write(bytes);
        }
        in.close();
        out.close();
    }
}

Related

  1. copyFile(File from, File to)
  2. copyFile(File from, File to)
  3. copyFile(File from, File to)
  4. copyFile(File from, File to)