Unanswered question

How to replace multiple text in a file using javascript?

Hi, need help.

I have a scenario where the multiple value from the file needs to be changed.

I have come up with the code (please refer to the file attached). What this code do is that, it reads the file first then there's an if condition. Inside If condition, that's where the value will be replaced.

id = line.replace("596791365558876095", "12345678");
date = line.replace("C6D-CN-NBB2829A", "C6D-CN-NBB1234A");
material = line.replace("323094-01", "123456-01");

var writer = new java.io.FileWriter("C:\\Peak2020\\Teemp\\TestDestination"+order+".xml",true);
writer.write(id);
writer.close();

The thing is when I write the result in the new file, it only replaces the first value because that's what I inputted in the writer.write(), but when I do this writer.write(id,date,material) it logs all the info which duplicated all the infos.

Can someone suggest what code do I need to use? Thank you.

Ann Jennifer E.
Ann Jennifer E.

Ann Jennifer E.

Level
0
55 / 100
points

Answers

Ann Jennifer E.
Ann Jennifer E.

Ann Jennifer E.

Level
0
55 / 100
points

This has been fixed. Thank you.