private static final char UTF_8_WITHOUT_BOM = '\ufeff';

private String saveUpdatedResult(String mailString) {
String fileName = DateUtils.
convertDateToString(new Date(), DateUtils.FORMAT_DATE_CALENDAR) + ".csv";
Path filePath = Paths.get(fileName);
try {
Files.
createFile(filePath);
try (BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(Files.newOutputStream(filePath, StandardOpenOption.TRUNCATE_EXISTING), "UTF-8"))) {
writer.write(
UTF_8_WITHOUT_BOM);
writer.write(convertHtmlToCSV(mailString));
}
return store(new File(fileName), fileName);
} catch (Exception e) {
log.warn("File create error. cause : ", e);
return null;
} finally {
try {
Files.
delete(filePath);
} catch (IOException e) {
log.warn("File delete fail. cause : ", e);
}
}
}

파일의 맨 앞에 \ufeff 을 넣어주면 된다. 하이고~..

+ Recent posts