/** * Encodes the given string into a sequence of bytes using the UTF-16LE 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[] getBytesUtf16Le(final String string) { return StringUtils.getBytesUnchecked(string, CharEncoding.UTF_16LE); }
/** * 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(final String string) { return StringUtils.getBytesUnchecked(string, CharEncoding.ISO_8859_1); }
/** * 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(final String string) { return StringUtils.getBytesUnchecked(string, CharEncoding.US_ASCII); }
/** * Encodes the given string into a sequence of bytes using the UTF-16 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[] getBytesUtf16(final String string) { return StringUtils.getBytesUnchecked(string, CharEncoding.UTF_16); }
/** * 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(final String string) { return StringUtils.getBytesUnchecked(string, CharEncoding.UTF_16BE); }
/** * Encodes the given string into a sequence of bytes using the UTF-8 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[] getBytesUtf8(final String string) { return StringUtils.getBytesUnchecked(string, CharEncoding.UTF_8); }