Here you can find the source of copyFiles(String from, String to)
public static void copyFiles(String from, String to)
//package com.java2s; /******************************************************************************* * Copyright (c) 2005, 2007 IBM Corporation and others. * 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 * //from w ww . j a v a 2 s .co m *******************************************************************************/ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import org.eclipse.dltk.core.DLTKCore; public class Main { public static void copyFiles(String from, String to) { File file = new File(from); File toFolder = new File(to); if (!file.exists() || !file.isDirectory()) { return; } File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) { File child = new File(toFolder, files[i].getName()); if (files[i].isDirectory()) { child.mkdir(); copyFiles(files[i].getAbsolutePath(), child.getAbsolutePath()); } else if (files[i].isFile()) { BufferedInputStream input; try { input = new BufferedInputStream(new FileInputStream(files[i])); org.eclipse.dltk.compiler.util.Util.copy(child, input); input.close(); } catch (FileNotFoundException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); } } catch (IOException e) { if (DLTKCore.DEBUG) { e.printStackTrace(); } } } child.setLastModified(files[i].lastModified()); } } }