Write File With Utf-8
I'm trying to write a file with utf-8 encoding. This file I would like to see on PC in Excel I've looked at enough examples of implementing this code. But I did not achieve the des
Solution 1:
I solved this problem!
FileOutputStream os = new FileOutputStream(sdCardFile);
os.write(0xef);<-!!!!!!!!
os.write(0xbb);<-!!!!!!!!
os.write(0xbf);<-!!!!!!!!
CSVWriter writer = new CSVWriter(new OutputStreamWriter(os), ';');
writer.writeNext(HEADER);
...
writer.writeNext('something data');
writer.close();
Solution 2:
I am not sure if this will help, but maybe formatting the string to UTF-8 this way can help:
bufferedWriter.write(newString(machinists.get(i).getLastName().getBytes(), "UTF-8"));
And similarly for the headers.
Edit:
Another thing you can try is to add "
for all the values and ,
as the delimiter (csv stands for "comma separated values" after all):
"1","Аркаев","10","7","6","5","0","6",
Post a Comment for "Write File With Utf-8"