ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 26312] - concat changes binary files
Date Fri, 30 Jan 2004 10:12:34 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26312>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26312

concat changes binary files





------- Additional Comments From peter.reilly@corvil.com  2004-01-30 10:12 -------
Just tested with the following:
    <scripttypedef name="encodedecode" language="beanshell">
      package scriptpackages;
      import java.io.*;
      import org.apache.tools.ant.Task;
      import org.apache.tools.ant.BuildException;
      public class EncodeDecode extends Task {
          private File source;
          private File dest;
          public void setSource(File source) {
              this.source = source;
          }
          public void setDest(File dest) {
              this.dest = dest;
          }
          public void execute() {
              if (source == null || dest == null) {
                  throw new BuildException("Missing source or dest");
              }
              Writer writer = null;
              Reader reader = null;
              try {
                  writer = new PrintWriter(
                      new BufferedWriter(new FileWriter(dest)));
                  reader = new BufferedReader(
                      new FileReader(source));
                  while (true) {
                      int ch = reader.read();
                      if (ch == -1) {
                          break;
                      }
                      writer.write(ch);
                  }
              } catch (Exception ex) {
                  throw new BuildException("exception", ex);
              } finally {
                  try { writer.close();} catch (Throwable t) {}
                  try { reader.close();} catch (Throwable t) {}
              }
          }
      }
    </scripttypedef>
    <encodedecode source="${ant.home}/lib/ant.jar"
                  dest="x.jar"/>

The input file is : 960963 bytes and the output file is 1628221.
Ps the default encodeing for readers may not be UTF-8, the doc only says that
it is locale dependant.

<copy> does not have this problem. It checks if thers are any filters or
filterchains and if not it uses InputStreams and OutputStreams and not
Readers and Writers. It may be possible to do something similar with
concat.

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


Mime
View raw message