Here you can find the source of copyFile(String fileName, File sourceRoot, File targetRoot, Set copied)
private static final void copyFile(String fileName, File sourceRoot, File targetRoot, Set copied) throws IOException
//package com.java2s; /**/*from w w w . j a v a 2 s . c om*/ * Create a the content for a readme file to accompany a configuration. * Basic configuration info, Jave and GoldenGATE version requirements, and * GoldenGATE software license are added automatically. A dialog allows for * entering a custom description text for the configuration, to be inserted * right below the basic info. This method returns the individual lines of * the readme file in an array of strings. If the dialog is cancelled, the * array is empty, but this method never returns null. * @param configName the name of the configuration to create a readme file * for * @param timestamp the creation timestamp of the configuration * @return the lines of the readme file in an array of strings, or an empty * array, if the input dialog was cancelled */ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Set; public class Main { private static final void copyFile(String fileName, File sourceRoot, File targetRoot, Set copied) throws IOException { // open source file File sourceFile = new File(sourceRoot, fileName); InputStream source = new BufferedInputStream(new FileInputStream(sourceFile)); // create target file File targetFile = new File(targetRoot, fileName); targetFile.getParentFile().mkdirs(); targetFile.createNewFile(); // open target file OutputStream target = new BufferedOutputStream(new FileOutputStream(targetFile)); // copy data int count; byte[] data = new byte[1204]; while ((count = source.read(data, 0, data.length)) != -1) target.write(data, 0, count); source.close(); target.flush(); target.close(); // set modification data of copy targetFile.setLastModified(sourceFile.lastModified()); } }