ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util FileUtils.java
Date Sun, 20 Jan 2002 09:54:46 GMT
donaldp     02/01/20 01:54:46

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/util
                        FileUtils.java
  Log:
  Cleaned up copy method
  
  Revision  Changes    Path
  1.17      +9 -16     jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java
  
  Index: FileUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- FileUtils.java	20 Jan 2002 02:11:45 -0000	1.16
  +++ FileUtils.java	20 Jan 2002 09:54:46 -0000	1.17
  @@ -19,6 +19,7 @@
   import java.util.Stack;
   import java.util.StringTokenizer;
   import org.apache.avalon.excalibur.io.FileUtil;
  +import org.apache.avalon.excalibur.io.IOUtil;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.types.FilterSetCollection;
   import org.apache.tools.ant.types.Path;
  @@ -31,7 +32,7 @@
    * @author duncan@x180.com
    * @author <a href="mailto:conor@apache.org">Conor MacNeill</a>
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
  - * @version $Revision: 1.16 $
  + * @version $Revision: 1.17 $
    */
   public class FileUtils
   {
  @@ -102,24 +103,16 @@
                       line = in.readLine();
                   }
   
  -                out.close();
  -                in.close();
  +                IOUtil.shutdownReader( in );
  +                IOUtil.shutdownWriter( out );
               }
               else
               {
  -                FileInputStream in = new FileInputStream( sourceFile );
  -                FileOutputStream out = new FileOutputStream( destFile );
  -
  -                byte[] buffer = new byte[ 8 * 1024 ];
  -                int count = 0;
  -                do
  -                {
  -                    out.write( buffer, 0, count );
  -                    count = in.read( buffer, 0, buffer.length );
  -                } while( count != -1 );
  -
  -                in.close();
  -                out.close();
  +                final FileInputStream in = new FileInputStream( sourceFile );
  +                final FileOutputStream out = new FileOutputStream( destFile );
  +                IOUtil.copy( in, out );
  +                IOUtil.shutdownStream( in );
  +                IOUtil.shutdownStream( out );
               }
           }
       }
  
  
  

--
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