You must save the line to a file. Here is the way I write to the file:
if (sc==6){ System.out.println("Введите новую книгу:"); Scanner console = new Scanner(System.in); try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Lib.txt")))){ out.println(console); }catch (IOException e){ System.err.println(e); } } But I can't even write anything, it automatically saves some incomprehensible message to the file.
java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false][group separator=\ ][decimal separator=\,][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q?\E][infinity string=\Q?\E]"