Here you can find the source of fileCopy(String from, String to)
Parameter | Description |
---|---|
from | filename to copy from |
to | filename to copy to |
static public void fileCopy(String from, String to) throws IOException
//package com.java2s; /**/*from ww w. ja va 2s. c o m*/ * Util.java * @author John Green * 27-Oct-2002 * www.joanju.com * * Copyright (c) 2002 Joanju Limited. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * */ import java.io.*; public class Main { /** Copy a file. * @param from filename to copy from * @param to filename to copy to */ static public void fileCopy(String from, String to) throws IOException { fileThing(from, to, false); } static private void fileThing(String from, String to, boolean append) throws IOException { BufferedReader in = new BufferedReader(new FileReader(from)); BufferedWriter out = new BufferedWriter(new FileWriter(to, append)); int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); } }