|
@@ -64,6 +64,8 @@ import java.io.FileReader; |
|
|
import java.io.FileWriter; |
|
|
import java.io.FileWriter; |
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
|
import java.io.OutputStreamWriter; |
|
|
import java.io.Reader; |
|
|
import java.io.Reader; |
|
|
|
|
|
|
|
|
import java.lang.reflect.Method; |
|
|
import java.lang.reflect.Method; |
|
@@ -157,6 +159,25 @@ public class FileUtils { |
|
|
overwrite, preserveLastModified); |
|
|
overwrite, preserveLastModified); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Convienence method to copy a file from a source to a |
|
|
|
|
|
* destination specifying if token filtering must be used, if |
|
|
|
|
|
* source files may overwrite newer destination files and the |
|
|
|
|
|
* last modified time of <code>destFile</code> file should be made equal |
|
|
|
|
|
* to the last modified time of <code>sourceFile</code>. |
|
|
|
|
|
* |
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
* |
|
|
|
|
|
* @since 1.14, Ant 1.5 |
|
|
|
|
|
*/ |
|
|
|
|
|
public void copyFile(String sourceFile, String destFile, |
|
|
|
|
|
FilterSetCollection filters, boolean overwrite, |
|
|
|
|
|
boolean preserveLastModified, String encoding) |
|
|
|
|
|
throws IOException { |
|
|
|
|
|
copyFile(new File(sourceFile), new File(destFile), filters, |
|
|
|
|
|
overwrite, preserveLastModified, encoding); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Convienence method to copy a file from a source to a destination. |
|
|
* Convienence method to copy a file from a source to a destination. |
|
|
* No filtering is performed. |
|
|
* No filtering is performed. |
|
@@ -202,6 +223,26 @@ public class FileUtils { |
|
|
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, |
|
|
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, |
|
|
boolean overwrite, boolean preserveLastModified) |
|
|
boolean overwrite, boolean preserveLastModified) |
|
|
throws IOException { |
|
|
throws IOException { |
|
|
|
|
|
copyFile(sourceFile, destFile, filters, overwrite, |
|
|
|
|
|
preserveLastModified, null); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Convienence method to copy a file from a source to a |
|
|
|
|
|
* destination specifying if token filtering must be used, if |
|
|
|
|
|
* source files may overwrite newer destination files, the last |
|
|
|
|
|
* modified time of <code>destFile</code> file should be made |
|
|
|
|
|
* equal to the last modified time of <code>sourceFile</code> and |
|
|
|
|
|
* which character encoding to assume. |
|
|
|
|
|
* |
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
* |
|
|
|
|
|
* @since 1.14, Ant 1.5 |
|
|
|
|
|
*/ |
|
|
|
|
|
public void copyFile(File sourceFile, File destFile, |
|
|
|
|
|
FilterSetCollection filters, boolean overwrite, |
|
|
|
|
|
boolean preserveLastModified, String encoding) |
|
|
|
|
|
throws IOException { |
|
|
|
|
|
|
|
|
if (overwrite || !destFile.exists() || |
|
|
if (overwrite || !destFile.exists() || |
|
|
destFile.lastModified() < sourceFile.lastModified()) { |
|
|
destFile.lastModified() < sourceFile.lastModified()) { |
|
@@ -218,8 +259,16 @@ public class FileUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (filters != null && filters.hasFilters()) { |
|
|
if (filters != null && filters.hasFilters()) { |
|
|
BufferedReader in = new BufferedReader(new FileReader(sourceFile)); |
|
|
|
|
|
BufferedWriter out = new BufferedWriter(new FileWriter(destFile)); |
|
|
|
|
|
|
|
|
BufferedReader in = null; |
|
|
|
|
|
BufferedWriter out = null; |
|
|
|
|
|
|
|
|
|
|
|
if (encoding == null) { |
|
|
|
|
|
in = new BufferedReader(new FileReader(sourceFile)); |
|
|
|
|
|
out = new BufferedWriter(new FileWriter(destFile)); |
|
|
|
|
|
} else { |
|
|
|
|
|
in = new BufferedReader(new InputStreamReader(new FileInputStream(sourceFile), encoding)); |
|
|
|
|
|
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(destFile), encoding)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
int length; |
|
|
int length; |
|
|
String newline = null; |
|
|
String newline = null; |
|
|