I want to ensure that my written CSV-file is encoded using UTF-8:
public StreamResource getExportDataAsCsv() {
return new StreamResource(new StreamResource.StreamSource() {
@Override
public InputStream getStream() {
List<Object[]> exportData = getExportData();
StringBuffer buffer = new StringBuffer();
buffer.append(someData);
byte[] bytes = buffer.toString().getBytes();
return new ByteArrayInputStream(bytes);
}
}, "MyExport.csv");
}
Unfortunately the found methods/ways to do so don't fit to my interface. Any ideas?
buffer.toString().getBytes("UTF-8");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.