How to get string.getBytes("UTF-8") throw UnsupportedEncodingException?
807588Jun 15 2009 — edited Jun 15 2009I am trying to get something like
String s = //somestring which is non utf-8 encoded
try {
s.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
// my code
}
I tried multiple things like
- using other encoding in the constructor
- reading some garbled data from files
- using charset encoders
It seems that string.getBytes() never throws any exception.