Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.net.URL;

public class Main {
    public static String validateIcalUrl(String url) {
        url = url.replace("page=calendar", "page=ical");
        if (!isValidURL(url))
            return null;
        return url;
    }

    public static boolean isValidURL(String url) {
        try {
            new URL(url).toURI(); // this is made to check whether its a valid URL
            return true;

        } catch (Exception ex) {
            return false;
        }
    }
}