Here you can find the source of getQueryFromURL(URL url)
public static Hashtable<String, String> getQueryFromURL(URL url)
//package com.java2s; /*// ww w .jav a2 s . c o m * (c) Copyright 2010-2011 AgileBirds * * This file is part of OpenFlexo. * * OpenFlexo is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * OpenFlexo is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OpenFlexo. If not, see <http://www.gnu.org/licenses/>. * */ import java.net.URL; import java.util.Hashtable; import java.util.StringTokenizer; public class Main { public static Hashtable<String, String> getQueryFromURL(URL url) { if (url == null || url.getQuery() == null) return new Hashtable<String, String>(); Hashtable<String, String> returned = new Hashtable<String, String>(); StringTokenizer st = new StringTokenizer(url.getQuery(), "&"); while (st.hasMoreTokens()) { StringTokenizer subSt = new StringTokenizer(st.nextToken(), "="); String key = null, value = null; if (subSt.hasMoreTokens()) key = subSt.nextToken(); if (subSt.hasMoreTokens()) value = subSt.nextToken(); if (key != null && value != null) returned.put(key, value); } return returned; } }