Since you're writing a csv
file, with comma
delimiter, and your text happens to have a comma
in it as well, you need to wrap your text within double quotes.
String names = ""hi,this is user"";
Note that to wrap your text within double quotes, you need to escape the double quotes as well!
Update:- A sample code snippet to wrap your string within double quotes.
public static void main(String[] args) {
String test = "abcd";
System.out.println(test); // prints abcd
test = appendDQ(test);
System.out.println(test); // prints "abcd"
}
private static String appendDQ(String str) {
return """ + str + """;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…