ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Fesler" <eric.fes...@hubmethods.com>
Subject extra CRLF when copying file with filtering
Date Thu, 28 Nov 2002 13:47:37 GMT
Hi,

Using ant 1.5, I just discover that ant is systematically adding an
extra CRLF at the end of the file when I used that copy task with
filtering set to true.

I've looked in the source and indeed, when the filters are applied, ant
is adding a new line at the end of each line.

In my case, this is an issue because the copied file is used as a
template for an email subject. The extra CRLF makes that the email
message header has an extra blank line and therefore is nomore compliant
with the email RFC.

Does anybody have an idea how to bypass this extra CRLF?

BTW, here is the code as I would correct it.

FileUtils.copyFile
...
if (filterChainsAvailable) {
	ChainReaderHelper crh = new ChainReaderHelper();
	crh.setBufferSize(8192);
	crh.setPrimaryReader(in);
	crh.setFilterChains(filterChains);
	crh.setProject(project);
	Reader rdr = crh.getAssembledReader();
	in = new BufferedReader(rdr);
}
int length;
String newline = null;
String line = in.readLine();
while (line != null) {
	if (line.length() == 0) {
		out.newLine();
	} else {
		if (filterSetsAvailable) {
			newline = filters.replaceTokens(line);
		} else {
			newline = line;
		}
		out.write(newline);
		// out.newLine();           // do not add it
systematically
	}
	line = in.readLine();
	if (line != null) out.newLine();  // Add the new line only id
really needed
}


--Eric



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


Mime
View raw message