ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umag...@apache.org
Subject cvs commit: jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/util FileUtils.java
Date Fri, 01 Mar 2002 00:17:19 GMT
umagesh     02/02/28 16:17:19

  Modified:    proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/util
                        FileUtils.java
  Log:
  Merge changes with the 1.14 revision from the main tree.
  
  Revision  Changes    Path
  1.2       +52 -3     jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/util/FileUtils.java
  
  Index: FileUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/util/FileUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileUtils.java	28 Feb 2002 21:59:04 -0000	1.1
  +++ FileUtils.java	1 Mar 2002 00:17:19 -0000	1.2
  @@ -64,6 +64,8 @@
   import java.io.FileWriter;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.io.InputStreamReader;
  +import java.io.OutputStreamWriter;
   import java.io.Reader;
   
   import java.lang.reflect.Method;
  @@ -86,7 +88,7 @@
    * @author <a href="mailto:conor@apache.org">Conor MacNeill</a>
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    *
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   
   public class FileUtils {
  @@ -158,6 +160,25 @@
       }
   
       /**
  +     * 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.
        * No filtering is performed.
        *
  @@ -202,6 +223,26 @@
       public void copyFile(File sourceFile, File destFile, FilterSetCollection filters,
                            boolean overwrite, boolean preserveLastModified)
           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() ||
               destFile.lastModified() < sourceFile.lastModified()) {
  @@ -218,8 +259,16 @@
               }
   
               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;
                   String newline = null;
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message