public static void encodeAndStream(byte[] id, int o, int l, OutputStream os) throws IOException { Base64Utility.encodeAndStream(id, o, l, true, os); } }
public static void encodeAndStream(byte[] id, int o, int l, OutputStream os) throws IOException { Base64Utility.encodeAndStream(id, o, l, true, os); } }
@Override public void flush() throws IOException { if (flushed || lastChunk == null) { return; } try { Base64Utility.encodeAndStream(lastChunk, 0, lastChunk.length, urlSafe, out); lastChunk = null; } catch (Exception ex) { throw new IOException(ex); } flushed = true; } private byte[] newArray(byte[] src, int srcPos, int srcLen) {
@Override public void flush() throws IOException { if (flushed || lastChunk == null) { return; } try { Base64Utility.encodeAndStream(lastChunk, 0, lastChunk.length, urlSafe, out); lastChunk = null; } catch (Exception ex) { throw new IOException(ex); } flushed = true; } private byte[] newArray(byte[] src, int srcPos, int srcLen) {
n -= left; if (n > 0) { Base64Utility.encodeAndStream(buffer, 0, n, output); total += n; if (n == -1) { Base64Utility.encodeAndStream(buffer, 0, left, output); total += left;
n -= left; if (n > 0) { Base64Utility.encodeAndStream(buffer, 0, n, output); total += n; if (n == -1) { Base64Utility.encodeAndStream(buffer, 0, left, output); total += left;
private void encodeAndWrite(byte[] b, int off, int len, boolean finalWrite) throws IOException { byte[] theChunk = lastChunk; int lenToEncode = len; if (theChunk != null) { theChunk = newArray(theChunk, 0, theChunk.length, b, off, len); lenToEncode = theChunk.length; off = 0; } else { theChunk = b; } int rem = finalWrite ? 0 : lenToEncode % 3; Base64Utility.encodeAndStream(theChunk, off, lenToEncode - rem, urlSafe, out); if (rem > 0) { lastChunk = newArray(theChunk, lenToEncode - rem, rem); } else { lastChunk = null; } }
private void encodeAndWrite(byte[] b, int off, int len, boolean finalWrite) throws IOException { byte[] theChunk = lastChunk; int lenToEncode = len; if (theChunk != null) { theChunk = newArray(theChunk, 0, theChunk.length, b, off, len); lenToEncode = theChunk.length; off = 0; } else { theChunk = b; } int rem = finalWrite ? 0 : lenToEncode % 3; Base64Utility.encodeAndStream(theChunk, off, lenToEncode - rem, urlSafe, out); if (rem > 0) { lastChunk = newArray(theChunk, lenToEncode - rem, rem); } else { lastChunk = null; } }
public static void encodeAndStream(byte[] id, int o, int l, boolean urlSafe, OutputStream os) throws IOException { if (l <= 0) { return; } int rindex = o; int rest = l; final char[] base64Table = urlSafe ? BCS_URL_SAFE : BCS; char[] chunk = new char[4]; while (rest >= 3) { int i = ((id[rindex] & 0xff) << 16) + ((id[rindex + 1] & 0xff) << 8) + (id[rindex + 2] & 0xff); chunk[0] = base64Table[i >> 18]; chunk[1] = base64Table[(i >> 12) & 0x3f]; chunk[2] = base64Table[(i >> 6) & 0x3f]; chunk[3] = base64Table[i & 0x3f]; writeCharArrayToStream(chunk, 4, os); rindex += 3; rest -= 3; } if (rest == 0) { return; } if (rest == 1) {
public static void encodeAndStream(byte[] id, int o, int l, boolean urlSafe, OutputStream os) throws IOException { if (l <= 0) { return; } int rindex = o; int rest = l; final char[] base64Table = urlSafe ? BCS_URL_SAFE : BCS; char[] chunk = new char[4]; while (rest >= 3) { int i = ((id[rindex] & 0xff) << 16) + ((id[rindex + 1] & 0xff) << 8) + (id[rindex + 2] & 0xff); chunk[0] = base64Table[i >> 18]; chunk[1] = base64Table[(i >> 12) & 0x3f]; chunk[2] = base64Table[(i >> 6) & 0x3f]; chunk[3] = base64Table[i & 0x3f]; writeCharArrayToStream(chunk, 4, os); rindex += 3; rest -= 3; } if (rest == 0) { return; } if (rest == 1) {