title: Writing byte array to an UTF8-encoded file
body: <p>Given a byte array in UTF-8 encoding (as result of <a href="https://github.com/Himmele/Mindroid.java/blob/master/src/mindroid/util/Base64.java" rel="nofollow">base64 decoding of a String</a>) - what is please a correct way to write it to a file in UTF-8 encoding?</p>
  
  <p>Is the following source code (writing the array byte by byte) correct?</p>
  
  <pre><code>OutputStreamWriter osw = new OutputStreamWriter(
      new FileOutputStream(tmpFile), Charset.forName("UTF-8"));
  for (byte b: buffer)
      osw.write(b);
  osw.close();
  </code></pre>