Hacker News new | past | comments | ask | show | jobs | submit login

Yes. Passing Charset arguments as String not only forces you to deal with the checked UnsupportedEncodingException, but it's also brittle: it's easy to make a typo (is it "utf8", "utf-8", "UTF8", or "UTF-8"?) and get a runtime failure.

Guava solves this problem by defining standard Charset constants in com.google.common.base.Charsets ( http://docs.guava-libraries.googlecode.com/git-history/v10.0... ). Java 7 also brings java.nio.charset.StandardCharsets ( http://download.oracle.com/javase/7/docs/api/java/nio/charse... ), but Guava will do for now :)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: