Base64.encode(cb, bytes, 0, bytes.length);
int len; int offset = 0;  try { while ((len = is.read(buffer, offset, buffer.length)) >= 0) { int tail = len % 3;  Base64.encode(cb, buffer, 0, len - tail);  System.arraycopy(buffer, len - tail, buffer, 0, tail); offset = tail; }  if (offset > 0) Base64.encode(cb, buffer, 0, offset); } catch (IOException e) { throw new RuntimeException(e); }  TempBuffer.free(tb);
  public static String base64_encode(String str)  {    CharBuffer cb = new CharBuffer();    byte []bytes = str.getBytes();    Base64.encode(cb, bytes, 0, bytes.length);    return cb.toString();  }