Java write escaped characters into file
I’m writing to a file and I need to escape some characters like a quotation mark. File fout = new File("output.txt"); try (FileOutputStream fos = new FileOutputStream(fout); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));) { String insert = "quote’s"; s += "’"+insert.replaceAll("’", "\\\’")+"’"; bw.write(s.replaceAll("\r\n", "\\\r\\\n")); bw.newLine(); } I’m trying to acheive writing ‘quote\’s’ to the file… Read More Java write escaped characters into file