public byte[] getBytes(String charsetName)
throws UnsupportedEncodingException Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array.
The behavior of this method when this string cannot be encoded in the given charset is unspecified. The CharsetEncoder class should be used when more control over the encoding process is required.
你看文档的解释:当string不能被编码的给定的字符集的时候,这个方法的行为是未知的。