return Encoder.RFC4648; return new Encoder(false, lineSeparator, lineLength >> 2 << 2, true);
/** * Encodes the specified byte array into a String using the {@link Base64} * encoding scheme. * * <p> This method first encodes all input bytes into a base64 encoded * byte array and then constructs a new String by using the encoded byte * array and the {@link java.nio.charset.StandardCharsets#ISO_8859_1 * ISO-8859-1} charset. * * <p> In other words, an invocation of this method has exactly the same * effect as invoking * {@code new String(encode(src), StandardCharsets.ISO_8859_1)}. * * @param src * the byte array to encode * @return A String containing the resulting Base64 encoded characters */ @SuppressWarnings("deprecation") public String encodeToString(byte[] src) { byte[] encoded = encode(src); return new String(encoded, 0, 0, encoded.length); }
int len = outLength(buffer.remaining()); byte[] dst = new byte[len]; int ret = 0; if (buffer.hasArray()) { ret = encode0(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.arrayOffset() + buffer.limit(), byte[] src = new byte[buffer.remaining()]; buffer.get(src); ret = encode0(src, 0, src.length, dst);
int len = outLength(buffer.remaining()); byte[] dst = new byte[len]; int ret = 0; if (buffer.hasArray()) { ret = encode0(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.arrayOffset() + buffer.limit(), byte[] src = new byte[buffer.remaining()]; buffer.get(src); ret = encode0(src, 0, src.length, dst);
int len = outLength(buffer.remaining()); byte[] dst = new byte[len]; int ret = 0; if (buffer.hasArray()) { ret = encode0(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.arrayOffset() + buffer.limit(), byte[] src = new byte[buffer.remaining()]; buffer.get(src); ret = encode0(src, 0, src.length, dst);
return Encoder.RFC4648; return new Encoder(false, lineSeparator, lineLength >> 2 << 2, true);
return Encoder.RFC4648; return new Encoder(false, lineSeparator, lineLength >> 2 << 2, true);
/** * Encodes all bytes from the specified byte array using the * {@link Base64} encoding scheme, writing the resulting bytes to the * given output byte array, starting at offset 0. * * <p> It is the responsibility of the invoker of this method to make * sure the output byte array {@code dst} has enough space for encoding * all bytes from the input byte array. No bytes will be written to the * output byte array if the output byte array is not big enough. * * @param src * the byte array to encode * @param dst * the output byte array * @return The number of bytes written to the output byte array * * @throws IllegalArgumentException if {@code dst} does not have enough * space for encoding all input bytes. */ public int encode(byte[] src, byte[] dst) { int len = outLength(src.length); // dst array size if (dst.length < len) throw new IllegalArgumentException( "Output byte array is too small for encoding all input bytes"); return encode0(src, 0, src.length, dst); }
/** * Encodes all bytes from the specified byte array using the * {@link Base64} encoding scheme, writing the resulting bytes to the * given output byte array, starting at offset 0. * * <p> It is the responsibility of the invoker of this method to make * sure the output byte array {@code dst} has enough space for encoding * all bytes from the input byte array. No bytes will be written to the * output byte array if the output byte array is not big enough. * * @param src * the byte array to encode * @param dst * the output byte array * @return The number of bytes written to the output byte array * * @throws IllegalArgumentException if {@code dst} does not have enough * space for encoding all input bytes. */ public int encode(byte[] src, byte[] dst) { int len = outLength(src.length); // dst array size if (dst.length < len) throw new IllegalArgumentException( "Output byte array is too small for encoding all input bytes"); return encode0(src, 0, src.length, dst); }
/** * Encodes the specified byte array into a String using the {@link Base64} * encoding scheme. * * <p> This method first encodes all input bytes into a base64 encoded * byte array and then constructs a new String by using the encoded byte * array and the {@link java.nio.charset.StandardCharsets#ISO_8859_1 * ISO-8859-1} charset. * * <p> In other words, an invocation of this method has exactly the same * effect as invoking * {@code new String(encode(src), StandardCharsets.ISO_8859_1)}. * * @param src * the byte array to encode * @return A String containing the resulting Base64 encoded characters */ @SuppressWarnings("deprecation") public String encodeToString(byte[] src) { byte[] encoded = encode(src); return new String(encoded, 0, 0, encoded.length); }
/** * Encodes the specified byte array into a String using the {@link Base64} * encoding scheme. * * <p> This method first encodes all input bytes into a base64 encoded * byte array and then constructs a new String by using the encoded byte * array and the {@link java.nio.charset.StandardCharsets#ISO_8859_1 * ISO-8859-1} charset. * * <p> In other words, an invocation of this method has exactly the same * effect as invoking * {@code new String(encode(src), StandardCharsets.ISO_8859_1)}. * * @param src * the byte array to encode * @return A String containing the resulting Base64 encoded characters */ @SuppressWarnings("deprecation") public String encodeToString(byte[] src) { byte[] encoded = encode(src); return new String(encoded, 0, 0, encoded.length); }
/** * Encodes all bytes from the specified byte array into a newly-allocated * byte array using the {@link Base64} encoding scheme. The returned byte * array is of the length of the resulting bytes. * * @param src * the byte array to encode * @return A newly-allocated byte array containing the resulting * encoded bytes. */ public byte[] encode(byte[] src) { int len = outLength(src.length); // dst array size byte[] dst = new byte[len]; int ret = encode0(src, 0, src.length, dst); if (ret != dst.length) return Arrays.copyOf(dst, ret); return dst; }
/** * Returns an encoder instance that encodes equivalently to this one, * but without adding any padding character at the end of the encoded * byte data. * * <p> The encoding scheme of this encoder instance is unaffected by * this invocation. The returned encoder instance should be used for * non-padding encoding operation. * * @return an equivalent encoder that encodes without adding any * padding character at the end */ public Encoder withoutPadding() { if (!doPadding) return this; return new Encoder(isURL, newline, linemax, false); }
/** * Encodes all bytes from the specified byte array into a newly-allocated * byte array using the {@link Base64} encoding scheme. The returned byte * array is of the length of the resulting bytes. * * @param src * the byte array to encode * @return A newly-allocated byte array containing the resulting * encoded bytes. */ public byte[] encode(byte[] src) { int len = outLength(src.length); // dst array size byte[] dst = new byte[len]; int ret = encode0(src, 0, src.length, dst); if (ret != dst.length) return Arrays.copyOf(dst, ret); return dst; }
/** * Returns an encoder instance that encodes equivalently to this one, * but without adding any padding character at the end of the encoded * byte data. * * <p> The encoding scheme of this encoder instance is unaffected by * this invocation. The returned encoder instance should be used for * non-padding encoding operation. * * @return an equivalent encoder that encodes without adding any * padding character at the end */ public Encoder withoutPadding() { if (!doPadding) return this; return new Encoder(isURL, newline, linemax, false); }
/** * Will encode byte array using Base64 encoding. * * @param input bytes to encode * @return encoded string */ public static String toBase64(byte[] input) { return Base64.getEncoder().encodeToString(input); }
/** * Will encode byte array using Base64 encoding. * * @param input bytes to encode * @return encoded string */ public static String toBase64(byte[] input) { return Base64.getEncoder().encodeToString(input); }
/** * Encodes all bytes from the specified byte array using the * {@link Base64} encoding scheme, writing the resulting bytes to the * given output byte array, starting at offset 0. * * <p> It is the responsibility of the invoker of this method to make * sure the output byte array {@code dst} has enough space for encoding * all bytes from the input byte array. No bytes will be written to the * output byte array if the output byte array is not big enough. * * @param src * the byte array to encode * @param dst * the output byte array * @return The number of bytes written to the output byte array * * @throws IllegalArgumentException if {@code dst} does not have enough * space for encoding all input bytes. */ public int encode(byte[] src, byte[] dst) { int len = outLength(src.length); // dst array size if (dst.length < len) throw new IllegalArgumentException( "Output byte array is too small for encoding all input bytes"); return encode0(src, 0, src.length, dst); }
/** * Encodes all bytes from the specified byte array into a newly-allocated * byte array using the {@link Base64} encoding scheme. The returned byte * array is of the length of the resulting bytes. * * @param src * the byte array to encode * @return A newly-allocated byte array containing the resulting * encoded bytes. */ public byte[] encode(byte[] src) { int len = outLength(src.length); // dst array size byte[] dst = new byte[len]; int ret = encode0(src, 0, src.length, dst); if (ret != dst.length) return Arrays.copyOf(dst, ret); return dst; }
/** * Returns an encoder instance that encodes equivalently to this one, * but without adding any padding character at the end of the encoded * byte data. * * <p> The encoding scheme of this encoder instance is unaffected by * this invocation. The returned encoder instance should be used for * non-padding encoding operation. * * @return an equivalent encoder that encodes without adding any * padding character at the end */ public Encoder withoutPadding() { if (!doPadding) return this; return new Encoder(isURL, newline, linemax, false); }