I am using PrintWriter to print some characters into the file. But when I use Println() to print a new line, the characters after new line are not visible.
Following is my code snippet
public void writeData(String data)
{
//PrintWriter csvWriter;
try
{
csvWriter = new PrintWriter(new FileWriter(file,true));
csvWriter.print(data+","+"hello");
//csvWriter.print("\r\n");
csvWriter.println();
csvWriter.print("world");
csvWriter.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
So in my file only the data & hello is visible. But “world” is not visible. I tried to print the new line using “\r\n” & “\n”. But nothing is working.
Somebody please help me….Thanks!
try this: