Here you can find the source of isAbsoluteUrl(String url)
Return the url is absolute url or not.
Parameter | Description |
---|---|
url | a parameter |
public static boolean isAbsoluteUrl(String url)
//package com.java2s; /*// w ww .j a v a2s .c o m * Copyright 2008-2010 the T2 Project ant the Others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { protected static final String VALID_SCHEME_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-"; /** * <#if locale="en"> * <p> * Return the url is absolute url or not. * * </p> * <#else> * <p> * * </p> * </#if> * * @param url * @return */ public static boolean isAbsoluteUrl(String url) { if (url == null) { return false; } int colonPos; if ((colonPos = url.indexOf(":")) == -1) { return false; } for (int i = 0; i < colonPos; i++) { if (VALID_SCHEME_CHARS.indexOf(url.charAt(i)) == -1) { return false; } } return true; } }