-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeb Caching.txt
More file actions
38 lines (36 loc) · 1.27 KB
/
Web Caching.txt
File metadata and controls
38 lines (36 loc) · 1.27 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
import java.sql.SQLOutput;
import java.util.*;
import java.net.*;
import java.awt.Desktop;
public class webcache {
public static void main(String[] args) throws Exception {
Scanner in=new Scanner(System.in);
HashSet<String> set = new HashSet<String>();
while(true) {
System.out.print("Enter website domain name : ");
String message;
message = in.nextLine();
if(message.equalsIgnoreCase("Exit")) break;
Desktop desk = Desktop.getDesktop();
InetAddress host = InetAddress.getByName(message);
String msg = host.toString();
int k = msg.indexOf('/');
String ip = msg.substring(k + 1);
System.out.println("The Domain IP is : " + ip);
desk.browse(new URI(message));
if (set.contains(message))
{
System.out.println("Fetched from cache");
}
else {
System.out.println("Not in cache, fetched from server");
set.add(message);
Iterator<String> i=set.iterator();
while(i.hasNext())
{
System.out.println(i.next());
}
}
}
}
}