{
return str.getBytes( UTF_CHARSET );
}
-
+
/**
* convert bytes to string
*
{
return new String( bytes, UTF_CHARSET );
}
-
+
+ /**
+ * convert string to bytes
+ *
+ * @param str string to convert
+ *
+ * @param str characterSet character set used to convert
+ *
+ * @return bytes to be converted
+ *
+ * @throws UnsupportedEncodingException If decoding fail
+ */
+ public static
+ byte[]
+ string2bytes(
+ final String str,
+ final String characterSet
+ )
+ throws UnsupportedEncodingException
+ {
+ return str.getBytes( characterSet );
+ }
+
+ /**
+ * convert bytes to string
+ *
+ * @param bytes byte[] to convert
+ *
+ * @param str characterSet character set used to convert
+ *
+ * @return string to be converted
+ *
+ * @throws UnsupportedEncodingException If encoding fail
+ */
+ public static
+ String
+ bytes2string(
+ final byte[] bytes,
+ final String characterSet
+ )
+ throws UnsupportedEncodingException
+ {
+ return new String( bytes, characterSet );
+ }
+
/**
* Return {@code true} if subsequence is equal
*