Java tutorial
//package com.java2s; import java.net.MalformedURLException; import java.net.URL; public class Main { public static String getNoQueryUrl(String source) { String dest = null; try { URL sUrl = new URL(source); URL dUrl = new URL(sUrl.getProtocol(), sUrl.getHost(), sUrl.getPort(), sUrl.getPath()); dest = dUrl.toString(); } catch (MalformedURLException e) { e.printStackTrace(); } return dest; } }