} else {
osw = new OutputStreamWriter(os, outputEncoding);
}
out = new BufferedWriter(osw);
if (filterChainsAvailable) {
ChainReaderHelper crh = new ChainReaderHelper();
crh.setBufferSize(FileUtils.BUF_SIZE);
crh.setPrimaryReader(in);
crh.setFilterChains(filterChains);
crh.setProject(project);
Reader rdr = crh.getAssembledReader();
in = new BufferedReader(rdr);
}
LineTokenizer lineTokenizer = new LineTokenizer();
lineTokenizer.setIncludeDelims(true);
String newline = null;
String line = lineTokenizer.getToken(in);
while (line != null) {
if (line.length() == 0) {
// this should not happen, because the lines are
// returned with the end of line delimiter
out.newLine();
} else {
newline = filters.replaceTokens(line);
out.write(newline);
}
line = lineTokenizer.getToken(in);
}
} finally {
FileUtils.close(out);
FileUtils.close(in);
}
} else if (filterChainsAvailable
|| (inputEncoding != null
&& !inputEncoding.equals(outputEncoding))
|| (inputEncoding == null && outputEncoding != null)) {
BufferedReader in = null;
BufferedWriter out = null;
try {
InputStreamReader isr = null;
if (inputEncoding == null) {
isr = new InputStreamReader(source.getInputStream());
} else {
isr = new InputStreamReader(source.getInputStream(),
inputEncoding);
}
in = new BufferedReader(isr);
OutputStream os = getOutputStream(dest, append, project);
OutputStreamWriter osw;
if (outputEncoding == null) {
osw = new OutputStreamWriter(os);
} else {
osw = new OutputStreamWriter(os, outputEncoding);
}
out = new BufferedWriter(osw);
if (filterChainsAvailable) {
ChainReaderHelper crh = new ChainReaderHelper();
crh.setBufferSize(FileUtils.BUF_SIZE);
crh.setPrimaryReader(in);
crh.setFilterChains(filterChains);
crh.setProject(project);
Reader rdr = crh.getAssembledReader();
in = new BufferedReader(rdr);
}
char[] buffer = new char[FileUtils.BUF_SIZE];
while (true) {
int nRead = in.read(buffer, 0, buffer.length);