Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import org.apache.http.NameValuePair;

public class Main {
    public static String prepareParameterizedGetUrl(String url, List<NameValuePair> params) {

        url += "?";
        if (params != null) {
            for (NameValuePair pair : params) {
                try {
                    url += pair.getName() + "=" + URLEncoder.encode(pair.getValue(), "UTF-8") + "&";
                } catch (UnsupportedEncodingException e) {

                    e.printStackTrace();
                    break;
                }

            }
            url = url.substring(0, url.trim().length() - 1);
        }
        return url;
    }
}