-
Notifications
You must be signed in to change notification settings - Fork 0
/
WordFinder.java
30 lines (25 loc) · 894 Bytes
/
WordFinder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.io.IOException;
import java.net.URL;
import java.util.Scanner;
public class WordFinder {
public static void main(String args[]) throws IOException {
// Initializing the URL class
URL url = new URL(args[0]);
// Reading the html page
Scanner read = new Scanner(url.openStream());
// Passing the content to a buffer
StringBuffer buffer = new StringBuffer();
while(read.hasNext()) {
buffer.append(read.next());
}
// Transforming all to string
String result = buffer.toString();
// Checking for the specific words: "senha", "black friday", "promoção" in the content
if (result.indexOf("senha") != -1 || result.indexOf("blackfriday") != -1 || result.indexOf("promoção") != -1){
System.out.println("suspicious");
}
else {
System.out.println("safe");
}
}
}