My groovy program creates a csv that is has \n for new line. But the customer wants \r\n as they run windows.
I understand that this question is answered a tonne of time on SO including here How to remove line breaks from a file in Java?
This script here does not replace \n with \r\n. The \n just stays on
newline = System.getProperty("line.separator");
for (int i = 0; i < dataContext.getDataCount(); i++) {
InputStream is = dataContext.getStream(i);
Properties props = dataContext.getProperties(i);
reader = new BufferedReader(new InputStreamReader(is));
outData = new StringBuffer();
lineNum = 0;
while ((line = reader.readLine()) != null) {
line.replace(newline, "\r\n")
outData.append(line);
}
is = new ByteArrayInputStream(outData.toString().getBytes("UTF-8"));
dataContext.storeStream(is, props);
}