Writing a byte array to a UTF8 encoded file
Given a UTF-8 encoded byte array (resulting in base64 decoding the string ) - what is the correct way to write this file in UTF-8 encoding please?
Is the following source code correct (writing array byte by byte)?
OutputStreamWriter osw = new OutputStreamWriter(
new FileOutputStream(tmpFile), Charset.forName("UTF-8"));
for (byte b: buffer)
osw.write(b);
osw.close();
+3
source to share