I am trying to edit a file with java.
I would like to escape every Quotation ” in my file with \”
I tried it like this (regards to the other solution on stackoverflow, which code I could copy):
public void replaceInFile(File file) throws IOException {
File tempFile = new File("twittergeoUpdate.csv");
FileWriter fw = new FileWriter(tempFile);
Reader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
while (br.ready()) {
fw.write(br.readLine().replaceAll("\"", "\\\"") + "\n");
}
fw.close();
br.close();
fr.close();
}
I was too fast… It doesn’t work for me. The Quotation just stay untouched in my file. Any ideas ?
\\\"only escapes"(double quote), you have to escape the back-slashes aswell, thus you need 5 backslashes.\\\\\"