I write the file line by line from the array, each line of the file in the end is an element of the array
// Π·Π°ΠΏΠΈΡΡ ΠΌΠ°ΡΡΠΈΠ²Π° Π² ΡΠ°ΠΉΠ» public static void recordFile(String fileName, String[] currentMassive) { try (FileWriter writer = new FileWriter(fileName, false)) { for (int count = 0; count < currentMassive.length; count++) { writer.write(currentMassive[count]); writer.append('\n'); } writer.flush(); } catch (IOException ex) { System.out.println(ex.getMessage()); } } The problem: for example, the array element has the following contents
currentMassive [count] = "1 \ n2 \ n3";
After saving to the file the following result is obtained:
... ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ count-2 ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ count-1 1 2 3 ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ count+1 ... And I expected to get the result in the form
... ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ count-2 ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ count-1 1*Π‘ΠΠ‘*2*Π‘ΠΠ‘*3 ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ count+1 ... where * ATP * is a newline character
Question: How does / (is it possible) to save a variable of type String, namely an element of an array, into a text file as a single line while preserving the characters of a newline?
Thank.
\andn. - Regent