Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. import java.net.*;
  2. import java.io.*;
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class WebTwo {
  7. public static void main(String[] args) throws Exception {
  8.  
  9. Scanner link = new Scanner(System.in);
  10.  
  11. System.out.println("Please type your link: ");
  12. URL o = new URL (link.nextLine());
  13.  
  14. BufferedReader in = new BufferedReader(
  15. new InputStreamReader(o.openStream()));
  16. PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("text.txt")));
  17.  
  18. int counter = 0;
  19.  
  20. String inputLine;
  21.  
  22. System.out.println("Please type in your keyword: ");
  23. Scanner key = new Scanner(System.in);
  24. String a = key.nextLine();
  25.  
  26. while ((inputLine = in.readLine()) != null) {
  27. if(inputLine.contains(a)) {
  28. inputLine = inputLine.replaceAll("\\<.*?\\>", "");
  29.  
  30. counter++;
  31. p.println(inputLine);
  32. }
  33. }
  34. System.out.println(a + " was found: "+counter +" times.");
  35. System.out.println("File Created");
  36. counter++;
  37.  
  38.  
  39.  
  40. try {
  41. in.close();
  42. p.close();
  43. } catch(Exception e) {
  44. e.printStackTrace();
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement