devutility.internal.data.codec.UTF8Utils Maven / Gradle / Ivy
package devutility.internal.data.codec;
import java.io.UnsupportedEncodingException;
public class UTF8Utils {
/**
* Encode value use UTF-8
* @param value: String value.
* @return byte[]
* @throws UnsupportedEncodingException
*/
public static byte[] encode(String value) throws UnsupportedEncodingException {
if (value == null) {
return null;
}
return value.getBytes("UTF-8");
}
/**
* Decode value use UTF-8
* @param bytes: Bytes array
* @return String
* @throws UnsupportedEncodingException
*/
public static String decode(byte[] bytes) throws UnsupportedEncodingException {
if (bytes == null || bytes.length == 0) {
return null;
}
return new String(bytes, "UTF-8");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy