code: public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked,
                                        final boolean urlSafe, final int maxResultSize) {
          if (binaryData == null || binaryData.length == 0) {
              return binaryData;
          }
  
          // Create this so can use the super-class method
          // Also ensures that the same roundings are performed by the ctor and the code
          final Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe);
          final long len = b64.getEncodedLength(binaryData);
          if (len > maxResultSize) {
              throw new IllegalArgumentException("Input array too big, the output array would be bigger (" +
                      len +
                      ") than the specified maximum size of " +
                      maxResultSize);
          }
  
          return b64.encode(binaryData);
      }
docs: Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
  
  @param binaryData    Array containing binary data to encode.
  @param isChunked     if <code>true</code> this encoder will chunk the base64 output into 76 character blocks
  @param urlSafe       if <code>true</code> this encoder will emit - and _ instead of the usual + and / characters.
  <b>Note: no padding is added when encoding using the URL-safe alphabet.</b>
  @param maxResultSize The maximum result size to accept.
  @return Base64-encoded data.
  @throws IllegalArgumentException Thrown when the input array needs an output array bigger than maxResultSize
  @since 1.4