How am I supposed to append a new line after I finish adding what I am supposed to. I have the following code:
try{
String textToAppend = question+userInput+","+typeOfAnswer;
Files.write(Paths.get("save.txt"), textToAppend.getBytes(), StandardOpenOption.APPEND);
}
catch (NoSuchFileException e){
}
catch(IOException e){
}
Example: question: By what initials was Franklin Roosevelt better known? userInput: RED typeOfAnswer will be wrong: wrong
I get my question and real answer from a file, then I compare the real answer with the userInput and see whether the typeOfAnswer si wrong/right. I want to output the question, userInput and typeOfAnswer in a File but I have multiple questions, hence I want to output the final results each on a new line.
textToAppend += System.lineSeparator();
- AndreastextToAppend = "\n"+question+userInput+","+typeOfAnswer
I won't get the new information in a new line. - RykBy what initials was Franklin Roosevelt better known?RED,wrongWhich number president was Franklin Roosevelt?RED,wrong
. There is no separation between wrong and Which - Ryk\n
as an end-of-line marker. Only\r\n
. - Andreas