Here you can find the source of getNormalizedURLString(String url)
Parameter | Description |
---|---|
url | a parameter |
private static String getNormalizedURLString(String url)
//package com.java2s; import java.net.URI; public class Main { /**//from ww w.jav a 2s .c om * * @param url * @return */ // ---------------------------------------------------------------------------------- private static String getNormalizedURLString(String url) { if (url != null) { try { StringBuffer buffer = new StringBuffer(); URI uri = new URI(url); String scheme = uri.getScheme().toLowerCase(); buffer.append(scheme); // scheme buffer.append("://"); buffer.append(uri.getHost().toLowerCase()); // host int port = uri.getPort(); if (port != -1 && ((scheme.compareTo("http") == 0 && port != 80) || (scheme .compareTo("https") == 0 && port != 433))) { buffer.append(":"); buffer.append(port); // port } buffer.append(uri.getPath()); // path String result = buffer.toString(); return result; } catch (Exception e) { e.printStackTrace(); } } return null; } }