Java tutorial
//package com.java2s; public class Main { /** * @brief Converting the url to lower case. * * @param strUrl [IN] url path * * @return Return modificated url string */ public static String fixUrl(String inUrl) { if (inUrl == null) { return null; } int colon = inUrl.indexOf(':'); boolean allLower = true; if (colon == -1) { inUrl = "http://" + inUrl; } for (int index = 0; index < colon; index++) { char ch = inUrl.charAt(index); if (!Character.isLetter(ch)) { break; } allLower &= Character.isLowerCase(ch); if (index == colon - 1 && !allLower) { inUrl = inUrl.substring(0, colon).toLowerCase() + inUrl.substring(colon); } } if (inUrl.startsWith("http://") || inUrl.startsWith("https://")) return inUrl; if (inUrl.startsWith("http:") || inUrl.startsWith("https:")) { if (inUrl.startsWith("http:/") || inUrl.startsWith("https:/")) { inUrl = inUrl.replaceFirst("/", "//"); } else inUrl = inUrl.replaceFirst(":", "://"); } return inUrl; } }