-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintWebPage.java
More file actions
55 lines (43 loc) · 1.18 KB
/
PrintWebPage.java
File metadata and controls
55 lines (43 loc) · 1.18 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
*
*/
package HtmlReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
/**
* @author rutpatel
*
*/
public class PrintWebPage {
public static void main(String[] args) throws IOException {
URL url = new URL("https://docs.oracle.com/javase/8/docs/api/java/util/TreeSet.html");
InputStream iS = url.openStream();
int count = 0, countS = 0;
// Scanner sc = new Scanner(iS);
// while (sc.hasNext()) {
// String data = sc.next();
// // System.out.println(data);
// if (data.toUpperCase().contains("COLLECTION")) {
// count++;
// }
// if (data.toUpperCase().contains("COLLECTIONS")) {
// countS++;
// }
// }
long startTime = System.currentTimeMillis();
String collection[] = new String(iS.readAllBytes()).split(" ");
for (int i = 0; i < collection.length; i++) {
if (collection[i].toLowerCase().contains("collection")) {
count++;
}
if (collection[i].toLowerCase().contains("collections")) {
count++;
}
}
long endTime = System.currentTimeMillis();
System.out.println("Total Time - " + (endTime - startTime) + " ms");
System.out.println("'Collection' Word Count - " + (count + countS));
// sc.close();
}
}