Java tutorial
//package com.java2s; import java.net.MalformedURLException; import java.net.URL; public class Main { public static String restoreAvatarUrl(String stringUrl) { try { StringBuilder sb = new StringBuilder(); URL url = new URL(stringUrl); sb.append(url.getProtocol()).append("://").append(url.getHost()).append(url.getPath()); return sb.toString(); } catch (MalformedURLException e) { return stringUrl; } } }