Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.FileReader;
- import java.net.InetAddress;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) throws Exception {
- FileReader file = new FileReader("in.txt");
- Scanner fr = new Scanner(file);
- Scanner sc = new Scanner(System.in);
- String url = sc.nextLine();
- String[] reg = url.split("/");
- String domen = reg[2];
- boolean ifurl = false, ifdomen = false, ifIP = false;
- int u = 0, d = 0, p = 0;
- InetAddress domenIP = InetAddress.getByName(domen);
- String IP = domenIP.toString().split("/")[1];
- while (fr.hasNextLine()){
- String[] line = fr.nextLine().split(";");
- String[] URLs = line[1].split(",");
- String[] Domens = line[2].split(",");
- String[] IPs = line[3].split(",");
- for (int i = 0; i < URLs.length; i++){
- if (url.compareTo(URLs[i]) == 0){
- ifurl = true;
- break;
- }
- }
- for (int i = 0; i < Domens.length; i++){
- if (domen.compareTo(Domens[i]) == 0){
- ifdomen = true;
- break;
- }
- }
- for (int i = 0; i < IPs.length; i++) {
- if (IP.compareTo(IPs[i]) == 0) {
- ifIP = true;
- break;
- }
- }
- }
- if (ifurl || ifdomen || ifIP){
- if (ifurl){
- System.out.println("URL blocked");
- }
- if (ifdomen){
- System.out.println("Domen blocked");
- }
- if (ifIP){
- System.out.println("IP blocked");
- }
- }
- else {
- System.out.println("Not blocked");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement