I created csv file in Java and inserted some values.This is source
try {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate localDate = LocalDate.now();
System.out.println(dtf.format(localDate).toString() + ".csv");
String filename = dtf.format(localDate).toString() + ".csv";
StringBuilder builder = new StringBuilder();
if (Files.exists(Paths.get("D:\\" + filename))) {
System.out.println("File existed");
} else {
System.out.println("File not found!");
String ColumnNamesList = "UID,name,personalNumber,nationality,dateofbirth,dateofexp,documentcode,gender,issueState,documentType";
builder.append(ColumnNamesList + "\n");
}
builder.append(UID + ",");
builder.append(name + ",");
builder.append(personalNumber + ",");
builder.append(nationality + ",");
builder.append(dateofbirth + ",");
builder.append(dateofexp + ",");
builder.append(documentcode + ",");
builder.append(gender + ",");
builder.append(issueState + ",");
builder.append(documentType + ",");
builder.append('\n');
File file = new File("D:\\" + filename);
FileWriter fw = new FileWriter(file, true); // the true will append the new data
fw.write(builder.toString());
fw.close();
System.out.println("done!");
} catch (IOException ioe) {
System.err.println("IOException: " + ioe.getMessage());
}
Problem is that,my "name" value is not English alphabet and result in my file is null. Is it a possible to add uft-8 support StringBuilder ? or how i can save some values in file with uft-8? thanks