Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.net.*;
- import java.io.*;
- import java.util.Scanner;
- public class WebTwo {
- public static void main(String[] args) throws Exception {
- Scanner link = new Scanner(System.in);
- System.out.println("Please type your link: ");
- URL o = new URL (link.nextLine());
- BufferedReader in = new BufferedReader(
- new InputStreamReader(o.openStream()));
- PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("text.txt")));
- int counter = 0;
- String inputLine;
- System.out.println("Please type in your keyword: ");
- Scanner key = new Scanner(System.in);
- String a = key.nextLine();
- while ((inputLine = in.readLine()) != null) {
- if(inputLine.contains(a)) {
- inputLine = inputLine.replaceAll("\\<.*?\\>", "");
- counter++;
- p.println(inputLine);
- }
- }
- System.out.println(a + " was found: "+counter +" times.");
- System.out.println("File Created");
- counter++;
- try {
- in.close();
- p.close();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement