Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get string.getBytes("UTF-8") throw UnsupportedEncodingException?

807588Jun 15 2009 — edited Jun 15 2009
I 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 13 2009
Added on Jun 15 2009
2 comments
2,217 views