Good day, I have such a problem. It is necessary to add text to the file, but from a new line. And it’s not easy to add, but what would the program request from the user when adding it? First: Title :, then Year :, and then Author’s name :. I use this method to write to the file, but it simply adds to the existing line.
if (sc==6){ System.out.println("Введите новую книгу:"); String filePath = "Lib.txt"; Scanner console = new Scanner(System.in); try {FileWriter out = new FileWriter(filePath, true); BufferedWriter bufferWriter = new BufferedWriter(out); bufferWriter.write(console.next()); bufferWriter.close(); } catch (IOException e) { System.err.println(e); } }