I'm using a buffered writer to write words in a text file, which works. But the writer starts at a new line every time, so you get all the words underneath each other with output.nextLine(); Can I check if a line is empty with an if statement so it wont print an empty line?
Here's the code:
BufferedWriter output = new BufferedWriter(new FileWriter("products.txt", true));
output.newLine();
output.append(s+" : "+price+" Euro");
output.close();
Because right now my txt file has an empty line at the top if I dont have text there.