Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**
     * Determine if a baseUrl string is in absolute or relative form. A empty string
     * "" or null para will return false.
     * 
     * @param url
     *            url string.
     * @return true if it is a absolute path starting with "http://" or
     *         "https://", case ignored.
     */
    public static boolean isAbsoluteUrl(String url) {
        if (isEmpty(url)) {
            return false;
        } else {
            String lowerUrl = url.trim().toLowerCase();
            return lowerUrl.startsWith("http://") || lowerUrl.startsWith("https://");
        }
    }

    /**
     * Returns true if the string is null or 0-length.
     * 
     * @param str
     *            the string to be examined
     * @return true if str is null or zero length
     */
    public static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }
}