Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1. package com.company;
  2. import java.net.Authenticator;
  3. import java.net.PasswordAuthentication;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8.     public static void main(String[] args) {
  9.  
  10.         try {
  11.            /* String down = args[0];k,kjlkj
  12.             String url = args[1];
  13.             int depth = Integer.parseInt(args[2]);
  14.             if(down.contains("download")) {*/
  15. //               Page page = new Page(url, depth);
  16.             int depth =2;
  17.             Page page = new Page("http://wiki.forbis.lt",depth);
  18.             if(depth>0) {
  19.                 if (depth == 1) {
  20.                     page.downloadPageInfo();
  21.                 }
  22.                 if(depth > 1){
  23.                     page.downloadPageInfo();
  24.                     page.depthRefing();
  25.                 }
  26.  
  27.             /*}else {
  28.                 System.out.println("not working");
  29.             }*/
  30.             }
  31.     }catch(NumberFormatException e){
  32.         e.getMessage();
  33.     }
  34.     }
  35.     static {
  36.  
  37.         System.out.println("user ir pass ivedimas: toks kaip prie pc su enter (proxiui)");
  38.         Scanner scanner = new Scanner(System.in);
  39.         String user = scanner.nextLine();
  40.         String pass = scanner.nextLine();
  41.  
  42.         Authenticator.setDefault(
  43.                 new Authenticator() {
  44.                     @Override
  45.                     public PasswordAuthentication getPasswordAuthentication() {
  46.                         return new PasswordAuthentication(
  47.                                 user, pass.toCharArray());
  48.                     }
  49.                 }
  50.         );
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement