Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * File    : TRTrackerClientUtils.java
 * Created : 29-Feb-2004
 * By      : parg
 * 
 * Azureus - a Java Bittorrent client
 *
 * This program 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 2 of the License.
 *
 * This program 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 ( see the LICENSE file ).
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.net.*;
import java.io.*;

public class Main {
    private static String[] BLACKLISTED_HOSTS = { "krypt.dyndns.org" };
    private static int[] BLACKLISTED_PORTS = { 81 };

    public static void checkForBlacklistedURLs(URL url)

            throws IOException {
        for (int i = 0; i < BLACKLISTED_HOSTS.length; i++) {

            if (url.getHost().equalsIgnoreCase(BLACKLISTED_HOSTS[i]) && url.getPort() == BLACKLISTED_PORTS[i]) {

                throw (new IOException(
                        "http://" + BLACKLISTED_HOSTS[i] + ":" + BLACKLISTED_PORTS[i] + "/ is not a tracker"));
            }
        }
    }
}