/** * Encodes the given string into a sequence of bytes using the US-ASCII charset, storing the * result into a new byte array. * * @param string the String to encode * @return encoded bytes * @throws IllegalStateException Thrown when the charset is missing, which should be never * according the the Java specification. * @see <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html">Standard * charsets</a> * @see #getBytesUnchecked(String, String) */ public static byte[] getBytesUsAscii(String string) { return StringUtils.getBytesUnchecked(string, CharEncoding.US_ASCII); }
/** * Encodes the given string into a sequence of bytes using the UTF-16BE charset, storing the * result into a new byte array. * * @param string the String to encode * @return encoded bytes * @throws IllegalStateException Thrown when the charset is missing, which should be never * according the the Java specification. * @see <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html">Standard * charsets</a> * @see #getBytesUnchecked(String, String) */ public static byte[] getBytesUtf16Be(String string) { return StringUtils.getBytesUnchecked(string, CharEncoding.UTF_16BE); }
/** * Encodes the given string into a sequence of bytes using the ISO-8859-1 charset, storing the * result into a new byte array. * * @param string the String to encode * @return encoded bytes * @throws IllegalStateException Thrown when the charset is missing, which should be never * according the the Java specification. * @see <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html">Standard * charsets</a> * @see #getBytesUnchecked(String, String) */ public static byte[] getBytesIso8859_1(String string) { return StringUtils.getBytesUnchecked(string, CharEncoding.ISO_8859_1); }