Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 *  Copyright 2012-2014 Quantcast Corp.
 *
 * This software is licensed under the Quantcast Mobile App Measurement Terms of Service
 * https://www.quantcast.com/learning-center/quantcast-terms/mobile-app-measurement-tos
 * (the License?). You may not use this file unless (1) you sign up for an account at
 * https://www.quantcast.com and click your agreement to the License and (2) are in
 * compliance with the License. See the License for the specific language governing
 * permissions and limitations under the License. Unauthorized use of this file constitutes
 * copyright infringement and violation of law.
 */

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class Main {
    protected static String encodeStringArray(String[] values) {
        if (values == null || values.length == 0)
            return null;

        String valueString = null;
        for (String value : values) {
            if (value != null) {
                try {
                    String encodedValue = URLEncoder.encode(value, "UTF-8");
                    //encodes space with "+" so change it to %20
                    encodedValue = encodedValue.replaceAll("\\+", "%20");
                    if (valueString == null) {
                        valueString = encodedValue;
                    } else {
                        valueString += "," + encodedValue;
                    }
                } catch (UnsupportedEncodingException ignored) {
                }
            }
        }
        return valueString;
    }
}