In Java, I have a String and I want to encode it as a byte array (in UTF8, or some other encoding). Alternately, I have a byte array (in some known encoding) and I want to convert it into a Java String. How do I do these conversions?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Here's a solution that avoids performing the Charset lookup for every conversion:
terribly late but i just encountered this issue and this is my fix:
As an alternative, StringUtils from Apache Commons can be used.
or
If you have non-standard charset, you can use getBytesUnchecked() or newString() accordingly.