Practical 15
Practical 15
Practical 15
Practical : 15
Q. Write a program using URL class to retrieve the host, protocol, port and
file of URL http://www.msbte.org.in ?
CODE:
import java.net.URL;
try {
URL url = new URL(urlsString);
System.out.println("URL" + urlsString);
System.out.println("Host" + url.getHost());
System.out.println("Protocol" + url.getProtocol());
System.out.println("Port" + url.getPort());
System.out.println("File" + url.getFile());
} catch (Exception e) {
System.out.println("ERROR" + e.getMessage());
e.getStackTrace();
}
}
}
OUTPUT:
Advanced Java Programming
Q. Write a program using URL and URLConnection class to retrieve the date,
content type, content length information of any entered URL?
CODE:
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
} else {
System.out.println("Date not available.");
}