Java URL is Absolute isAbsoluteURL(String url)

Here you can find the source of isAbsoluteURL(String url)

Description

Return true if the URL given in parameter is absolute

License

Open Source License

Parameter

Parameter Description
url String the url string to test

Return

boolean true if the url is absolute, false otherwise

Declaration

public static boolean isAbsoluteURL(String url) 

Method Source Code

//package com.java2s;
/*// ww  w.j  av  a2  s  .c  o  m
  This file is part of JOrigin Common Library.
    
JOrigin Common is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
JOrigin Common is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with JOrigin Common.  If not, see <http://www.gnu.org/licenses/>.
    
*/

public class Main {
    /**
     * Return true if the URL given in parameter is absolute
     * @param url String the url string to test
     * @return boolean true if the url is absolute, false otherwise
     */
    public static boolean isAbsoluteURL(String url) {
        if (url.startsWith("file:/") || (url.startsWith("http:/"))) {
            return true;
        }
        return false;
    }
}

Related

  1. isAbsoluteUrl(String ref)
  2. isAbsoluteURL(String str)
  3. isAbsoluteURL(String url)
  4. isAbsoluteUrl(String url)
  5. isAbsoluteURL(String url)