title: Proper decoding of byte array to char array
body: <p>In making password handling more secure by eliminating storage in Strings (which end up on the heap).  I have the following existing code:</p>
  
  <pre><code>String pw = new String(buffer, 0, len, "UTF-32LE");
  </code></pre>
  
  <p>I came up with:</p>
  
  <pre><code>Charset charSet = Charset.forName("UTF-32LE");
  ByteBuffer byteBuffer = ByteBuffer.wrap(buffer, 0, len);
  CharBuffer charBuffer = charSet.decode(byteBuffer);
  charArray = new char[charBuffer.length()];
  for (int i = 0; i &lt; charBuffer.length(); ++i)
  {
      charArray[i] = charBuffer.charAt(i);
  }
  </code></pre>
  
  <p>Note that we support many different languages, so I'm not quite sure how best to thoroughly test this approach.</p>
  
  <ol>
  <li>Is this correct?  Are there caveats to this approach?</li>
  <li>Is this the best approach or am I missing something simpler?</li>
  </ol>
  
  <p>Thanks for any feedback or advice.</p>