Java BufferedReader Copy copyFile(File from, File to)

Here you can find the source of copyFile(File from, File to)

Description

copy File

License

Open Source License

Declaration

static public void copyFile(File from, File to) throws IOException 

Method Source Code


//package com.java2s;
/*/*from ww w  .ja v  a  2s .c  om*/
 RoadRunner - an automatic wrapper generation system for Web data sources
 Copyright (C) 2003  Valter Crescenzi - crescenz@dia.uniroma3.it
    
 This program 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 2 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
 General Public License for more details.
    
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the:
    
 Free Software Foundation, Inc.,
 59 Temple Place, Suite 330,
 Boston, MA 02111-1307 USA
    
 ----
    
 RoadRunner - un sistema per la generazione automatica di wrapper su sorgenti Web
 Copyright (C) 2003  Valter Crescenzi - crescenz@dia.uniroma3.it
    
 Questo  programma  software libero;   lecito redistribuirlo  o
 modificarlo secondo i termini della Licenza Pubblica Generica GNU
 come ? pubblicata dalla Free Software Foundation; o la versione 2
 della licenza o (a propria scelta) una versione successiva.
    
 Questo programma   distribuito nella speranza che sia  utile, ma
 SENZA  ALCUNA GARANZIA;  senza neppure la  garanzia implicita  di
 NEGOZIABILIT?  o di  APPLICABILIT? PER  UN PARTICOLARE  SCOPO. Si
 veda la Licenza Pubblica Generica GNU per avere maggiori dettagli.
    
 Questo  programma deve  essere  distribuito assieme  ad una copia
 della Licenza Pubblica Generica GNU; in caso contrario, se ne pu
 ottenere  una scrivendo  alla:
    
 Free  Software Foundation, Inc.,
 59 Temple Place, Suite 330,
 Boston, MA 02111-1307 USA
    
*/

import java.io.*;

public class Main {
    static public void copyFile(File from, File to) throws IOException {
        Reader reader = new BufferedReader(new FileReader(from));
        Writer writer = new BufferedWriter(new FileWriter(to));
        int ch;
        while ((ch = reader.read()) != -1) {
            writer.write(ch);
        }
        reader.close();
        writer.close();
    }
}

Related

  1. copyFile(BufferedReader in, BufferedWriter out)
  2. copyFile(File orgFile, File dstFile)
  3. copyFile(File original, File copy)
  4. copyFile(File source, File dest)
  5. copyFile(File src, File dst)