Code example for UrlEncodedFormEntity

0
        // check if entity was explictly set otherwise return params as entity 
        if (entity.getContentLength() > 0) {
            return entity;
        } else if (!params.isEmpty()) {
            // construct entity if not already set 
            return new UrlEncodedFormEntity(params, DEFAULT_ENCODING);
        } 
        return null; 
    } 
 
    public static String base64Encode(String str) {
        byte[] bytes = str.getBytes();
        return Base64.encodeToString(bytes, Base64.NO_WRAP);
    } 
 
    public static Throwable getRootCause(Throwable throwable) {
        if (throwable.getCause() != null) {
            return getRootCause(throwable.getCause());
        } 
        return throwable;
    }