/** * 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); }
/** * Constructs a new <code>String</code> by decoding the specified array of bytes using the * UTF-16 charset. * * @param bytes * The bytes to be decoded into characters * @return A new <code>String</code> decoded from the specified array of bytes using the given * charset. * @throws IllegalStateException * Thrown when a {@link UnsupportedEncodingException} is caught, which should never * happen since the charset is required. */ public static String newStringUtf16(final byte[] bytes) { return StringUtils.newString(bytes, CharEncoding.UTF_16); }
/** * Encodes binary data using the base64 algorithm into 76 character blocks separated by CRLF. * * @param binaryData * binary data to encode * @return String containing Base64 characters. * @since 1.4 */ public static String encodeBase64String(final byte[] binaryData) { return StringUtils.newStringUtf8(encodeBase64(binaryData, true)); }
throw StringUtils.newIllegalStateException(charsetName, e);
/** * Decodes a String containing containing characters in the Base64 alphabet. * * @param pArray * A String containing Base64 character data * @return a byte array containing binary data * @since 1.4 */ public byte[] decode(final String pArray) { return decode(StringUtils.getBytesUtf8(pArray)); }
/** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the * output. The url-safe variation emits - and _ instead of + and / characters. * * @param binaryData * binary data to encode * @return String containing Base64 characters * @since 1.4 */ public static String encodeBase64URLSafeString(final byte[] binaryData) { return StringUtils.newStringUtf8(encodeBase64(binaryData, false, true)); }
throw StringUtils.newIllegalStateException(charsetName, e);
/** * Constructs a new <code>String</code> by decoding the specified array of bytes using the * UTF-16BE charset. * * @param bytes * The bytes to be decoded into characters * @return A new <code>String</code> decoded from the specified array of bytes using the given * charset. * @throws IllegalStateException * Thrown when a {@link UnsupportedEncodingException} is caught, which should never * happen since the charset is required. */ public static String newStringUtf16Be(final byte[] bytes) { return StringUtils.newString(bytes, CharEncoding.UTF_16BE); }
/** * 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 a byte[] containing binary data, into a String containing characters in the Base64 * alphabet. * * @param pArray * a byte array containing binary data * @return A String containing only Base64 character data * @since 1.4 */ public String encodeToString(final byte[] pArray) { return StringUtils.newStringUtf8(encode(pArray)); }
/** * Constructs a new <code>String</code> by decoding the specified array of bytes using the UTF-8 * charset. * * @param bytes * The bytes to be decoded into characters * @return A new <code>String</code> decoded from the specified array of bytes using the given * charset. * @throws IllegalStateException * Thrown when a {@link UnsupportedEncodingException} is caught, which should never * happen since the charset is required. */ public static String newStringUtf8(final byte[] bytes) { return StringUtils.newString(bytes, CharEncoding.UTF_8); } }
/** * 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); }
if (containsBase64Byte(lineSeparator)) String sep = StringUtils.newStringUtf8(lineSeparator); throw new IllegalArgumentException( "lineSeperator must not contain base64 characters: [" + sep + "]");
/** * Constructs a new <code>String</code> by decoding the specified array of bytes using the * US-ASCII charset. * * @param bytes * The bytes to be decoded into characters * @return A new <code>String</code> decoded from the specified array of bytes using the given * charset. * @throws IllegalStateException * Thrown when a {@link UnsupportedEncodingException} is caught, which should never * happen since the charset is required. */ public static String newStringUsAscii(final byte[] bytes) { return StringUtils.newString(bytes, 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); }
/** * Constructs a new <code>String</code> by decoding the specified array of bytes using the * UTF-16LE charset. * * @param bytes * The bytes to be decoded into characters * @return A new <code>String</code> decoded from the specified array of bytes using the given * charset. * @throws IllegalStateException * Thrown when a {@link UnsupportedEncodingException} is caught, which should never * happen since the charset is required. */ public static String newStringUtf16Le(final byte[] bytes) { return StringUtils.newString(bytes, CharEncoding.UTF_16LE); }
/** * 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); }
/** * Constructs a new <code>String</code> by decoding the specified array of bytes using the * ISO-8859-1 charset. * * @param bytes * The bytes to be decoded into characters * @return A new <code>String</code> decoded from the specified array of bytes using the given * charset. * @throws IllegalStateException * Thrown when a {@link UnsupportedEncodingException} is caught, which should never * happen since the charset is required. */ public static String newStringIso8859_1(final byte[] bytes) { return StringUtils.newString(bytes, CharEncoding.ISO_8859_1); }
/** * 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); }