ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Concat.java
Date Mon, 18 Nov 2002 15:26:59 GMT
bodewig     2002/11/18 07:26:59

  Modified:    .        Tag: ANT_15_BRANCH WHATSNEW
               src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
                        Concat.java
  Log:
  Merge fix for PR12511 from HEAD
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.263.2.101 +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.263.2.100
  retrieving revision 1.263.2.101
  diff -u -r1.263.2.100 -r1.263.2.101
  --- WHATSNEW	18 Nov 2002 12:03:29 -0000	1.263.2.100
  +++ WHATSNEW	18 Nov 2002 15:26:58 -0000	1.263.2.101
  @@ -31,6 +31,8 @@
   
   * <cvschangelog> could miss today's changes.
   
  +* <concat> could append newline characters between concatenated files.
  +
   Other changes:
   --------------
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.4   +21 -17    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Concat.java
  
  Index: Concat.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Concat.java,v
  retrieving revision 1.5.2.3
  retrieving revision 1.5.2.4
  diff -u -r1.5.2.3 -r1.5.2.4
  --- Concat.java	12 Nov 2002 12:21:32 -0000	1.5.2.3
  +++ Concat.java	18 Nov 2002 15:26:58 -0000	1.5.2.4
  @@ -74,8 +74,8 @@
   import java.io.InputStreamReader;
   import java.io.OutputStream;
   import java.io.OutputStreamWriter;
  -import java.io.PrintWriter;
   import java.io.StringReader;
  +import java.io.Writer;
   
   import java.util.Vector; // 1.1
   import java.util.Enumeration; // 1.1
  @@ -364,7 +364,7 @@
                       }
   
                       is = new FileInputStream(input[i]);
  -                    byte[] buffer = new byte[8096];
  +                    byte[] buffer = new byte[8192];
                       while (true) {
                           int bytesRead = is.read(buffer);
                           if (bytesRead == -1) { // EOF
  @@ -394,24 +394,22 @@
                   }
               }
   
  -        } else { // user specified encoding, assume line oriented input
  +        } else { // user specified encoding
   
  -            PrintWriter out = null;
  +            Writer out = null;
               BufferedReader in = null;
   
               try {
                   if (destinationFile == null) {
                       // Log using WARN so it displays in 'quiet' mode.
  -                    out = new PrintWriter(
  -                              new OutputStreamWriter(
  -                                  new LogOutputStream(this, Project.MSG_WARN)));
  +                    out = new OutputStreamWriter(
  +                              new LogOutputStream(this, Project.MSG_WARN));
                   } else {
  -                    out = new PrintWriter(
  -                              new OutputStreamWriter(
  -                                  new FileOutputStream(destinationFile
  -                                                       .getAbsolutePath(),
  -                                                       append),
  -                                  encoding));
  +                    out = new OutputStreamWriter(
  +                              new FileOutputStream(destinationFile
  +                                                   .getAbsolutePath(),
  +                                                   append),
  +                              encoding);
                       
                       // This flag should only be recognized for the first
                       // file. In the context of a single 'cat', we always
  @@ -425,11 +423,17 @@
                                   encoding));
   
                       String line;
  -                    while ((line = in.readLine()) != null) {
  -                        // Log the line, using WARN so it displays in
  -                        // 'quiet' mode.
  -                        out.println(line);
  +                    char[] buffer = new char[4096];
  +                    while (true) {
  +                        int charsRead = in.read(buffer);
  +                        if (charsRead == -1) { // EOF
  +                            break;
  +                        }
  +                        
  +                        // Write the read data.
  +                        out.write(buffer, 0, charsRead);
                       }
  +                    out.flush();
                       in.close();
                       in = 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