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.URLDecoder;

public class Main {
    public static String findValueInUrl(String url, String key) {
        String[] params = url.split("&");

        String value = "";

        for (String p : params) {
            if (p.contains(key)) {
                try {
                    value = URLDecoder.decode(p.split("=")[1], "utf-8");
                } catch (UnsupportedEncodingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }

        return value;
    }
}