code: public static String encodeB(byte[] bytes) {
  		StringBuilder sb = new StringBuilder();
  
  		int idx = 0;
  		final int end = bytes.length;
  		for (; idx < end - 2; idx += 3) {
  			int data = (bytes[idx] & 0xff) << 16 | (bytes[idx + 1] & 0xff) << 8 | bytes[idx + 2] & 0xff;
  			sb.append((char) BASE64_TABLE[data >> 18 & 0x3f]);
  			sb.append((char) BASE64_TABLE[data >> 12 & 0x3f]);
  			sb.append((char) BASE64_TABLE[data >> 6 & 0x3f]);
  			sb.append((char) BASE64_TABLE[data & 0x3f]);
  		}
  
  		if (idx == end - 2) {
  			int data = (bytes[idx] & 0xff) << 16 | (bytes[idx + 1] & 0xff) << 8;
  			sb.append((char) BASE64_TABLE[data >> 18 & 0x3f]);
  			sb.append((char) BASE64_TABLE[data >> 12 & 0x3f]);
  			sb.append((char) BASE64_TABLE[data >> 6 & 0x3f]);
  			sb.append((char) BASE64_PAD);
  
  		} else if (idx == end - 1) {
  			int data = (bytes[idx] & 0xff) << 16;
  			sb.append((char) BASE64_TABLE[data >> 18 & 0x3f]);
  			sb.append((char) BASE64_TABLE[data >> 12 & 0x3f]);
  			sb.append((char) BASE64_PAD);
  			sb.append((char) BASE64_PAD);
  		}
  
  		return sb.toString();
  	}
docs: Encodes the specified byte array using the B encoding defined in RFC 2047.
  
  @param bytes
  byte array to encode.
  @return encoded string.