checkNewline(); out.write(base64[b0 >> 2]); out.write(base64[(b0 << 4) & 0x3f | (b1 >> 4)]); leftover = len - (nBits24 * 3); while (nBits24-- > 0) { checkNewline(); int bits = (b[off++] & 0xff) << 16 | (b[off++] & 0xff) << 8 |
checkNewline(); out.write(base64[b0 >> 2]); out.write(base64[(b0 << 4) & 0x3f | (b1 >> 4)]); leftover = len - (nBits24 * 3); while (nBits24-- > 0) { checkNewline(); int bits = (b[off++] & 0xff) << 16 | (b[off++] & 0xff) << 8 |
checkNewline(); out.write(base64[b0 >> 2]); out.write(base64[(b0 << 4) & 0x3f | (b1 >> 4)]); leftover = len - (nBits24 * 3); while (nBits24-- > 0) { checkNewline(); int bits = (b[off++] & 0xff) << 16 | (b[off++] & 0xff) << 8 |
@Override public void close() throws IOException { if (!closed) { closed = true; if (leftover == 1) { checkNewline(); out.write(base64[b0 >> 2]); out.write(base64[(b0 << 4) & 0x3f]); if (doPadding) { out.write('='); out.write('='); } } else if (leftover == 2) { checkNewline(); out.write(base64[b0 >> 2]); out.write(base64[(b0 << 4) & 0x3f | (b1 >> 4)]); out.write(base64[(b1 << 2) & 0x3f]); if (doPadding) { out.write('='); } } leftover = 0; out.close(); } } }
@Override public void close() throws IOException { if (!closed) { closed = true; if (leftover == 1) { checkNewline(); out.write(base64[b0 >> 2]); out.write(base64[(b0 << 4) & 0x3f]); if (doPadding) { out.write('='); out.write('='); } } else if (leftover == 2) { checkNewline(); out.write(base64[b0 >> 2]); out.write(base64[(b0 << 4) & 0x3f | (b1 >> 4)]); out.write(base64[(b1 << 2) & 0x3f]); if (doPadding) { out.write('='); } } leftover = 0; out.close(); } } }
/** * Wraps an output stream for encoding byte data using the {@link Base64} * encoding scheme. * * <p> It is recommended to promptly close the returned output stream after * use, during which it will flush all possible leftover bytes to the underlying * output stream. Closing the returned output stream will close the underlying * output stream. * * @param os * the output stream. * @return the output stream for encoding the byte data into the * specified Base64 encoded format */ public OutputStream wrap(OutputStream os) { the(os).shouldNotBeNull(); return new EncOutputStream(os, isURL ? toBase64URL : toBase64, newline, linemax, doPadding); }
/** * Wraps an output stream for encoding byte data using the {@link Base64} * encoding scheme. * * <p> It is recommended to promptly close the returned output stream after * use, during which it will flush all possible leftover bytes to the underlying * output stream. Closing the returned output stream will close the underlying * output stream. * * @param os * the output stream. * @return the output stream for encoding the byte data into the * specified Base64 encoded format */ public OutputStream wrap(OutputStream os) { the(os).shouldNotBeNull(); return new EncOutputStream(os, isURL ? toBase64URL : toBase64, newline, linemax, doPadding); }
@Override public void write(int b) throws IOException { byte[] buf = new byte[1]; buf[0] = (byte)(b & 0xff); write(buf, 0, 1); }
@Override public void write(int b) throws IOException { byte[] buf = new byte[1]; buf[0] = (byte)(b & 0xff); write(buf, 0, 1); }
@Override public void close() throws IOException { if (!closed) { closed = true; if (leftover == 1) { checkNewline(); out.write(base64[b0 >> 2]); out.write(base64[(b0 << 4) & 0x3f]); if (doPadding) { out.write('='); out.write('='); } } else if (leftover == 2) { checkNewline(); out.write(base64[b0 >> 2]); out.write(base64[(b0 << 4) & 0x3f | (b1 >> 4)]); out.write(base64[(b1 << 2) & 0x3f]); if (doPadding) { out.write('='); } } leftover = 0; out.close(); } } }
/** * Wraps an output stream for encoding byte data using the {@link Base64} * encoding scheme. * * <p> It is recommended to promptly close the returned output stream after * use, during which it will flush all possible leftover bytes to the underlying * output stream. Closing the returned output stream will close the underlying * output stream. * * @param os * the output stream. * @return the output stream for encoding the byte data into the * specified Base64 encoded format */ public OutputStream wrap(OutputStream os) { the(os).shouldNotBeNull(); return new EncOutputStream(os, isURL ? toBase64URL : toBase64, newline, linemax, doPadding); }
@Override public void write(int b) throws IOException { byte[] buf = new byte[1]; buf[0] = (byte)(b & 0xff); write(buf, 0, 1); }