I try to generate a CSV file, the data is separated with a comma ",", and new line with "\n". The new line is working, but not the comma, I have all the data in the first column, not in two columns as I wish.
Here is the code:
BufferedWriter writer = new BufferedWriter(new FileWriter("test.csv"));
writer.write("Username");
writer.write(",");
writer.write("Count");
writer.write("\n");
writer.write("Bob");
writer.write(",");
writer.write("20");
writer.write("\n");
writer.write("Mike");
writer.write(",");
writer.write("32");
writer.write("\n");
writer.close();
The result is this:
Username,Count
Bob,20
Mike,32
The expected result is something like that
Username | Count
------ | ------
Bob | 20
------ | ------
Mike | 32
;as a separator in a txt file then change the extension, not with,... don't ask whysep=,as mentioned in superuser.com/a/686415/371154. But still we can't be sure that this is what OP wants until OP will clarify his problem.