public class WebsiteTester
extends java.lang.Object
| Constructor and Description |
|---|
WebsiteTester() |
| Modifier and Type | Method and Description |
|---|---|
void |
downloadText() |
java.lang.String |
getContent()
This method will return the contents that ahve been downloaded from the
given site.
|
long |
getDownloadTime()
This method will obtain the download time in MS for the given file.
|
java.lang.String |
getHostname()
This method will return the hostname for the given machine which is
hosting the website.
|
int |
getPort()
This method will return the Port that the system is connected to.
|
int |
getSize()
This method will return the size of the downloaded web resource.
|
java.lang.String |
getTimeout()
This method will return the current timeout as a string.
|
boolean |
isUrlSet()
This method will determine if the URL that is to be accessed has been
initialized.
|
void |
openConnection()
This method will open a connection with a remote site in order that the
page can be downloaded.
|
void |
openURL(java.lang.String url)
This method will convert a string into a URL that can be accessed.
|
void |
setTimeout(java.lang.String timeout)
This method will set the timeout, or how long the system will wait for a
connection from the remote server.
|
public void openURL(java.lang.String url)
throws java.net.MalformedURLException
url - This is a string representation for the URL. The string should
includejava.net.MalformedURLException - This exception will be thrown if the url passed in does not
represent a valid URL.public void openConnection()
throws java.net.MalformedURLException,
java.net.UnknownHostException,
java.net.SocketTimeoutException,
java.io.IOException
java.net.MalformedURLException - This exception will be thrown if the url passed in does not
represent a valid URL.java.net.UnknownHostException - This exception will be thrown if the system is unable to
connect to the remote host because while the URL is a vlaid
URL, it does not reference a machien which is online.java.net.SocketTimeoutException - This exception will be thrown if it is taking too long to
connect to the given machine.java.io.IOException - This exception will be thrown if there is another IO
exception opening the connection with the remote machine.public void downloadText()
throws java.net.UnknownHostException,
java.net.ConnectException,
java.io.FileNotFoundException,
java.io.IOException
java.net.UnknownHostException - This exception will be thrown if the system is unable to
connect to the remote host because while the URL is a vlaid
URL, it does not reference a machien which is online.java.net.ConnectException - This exception will be thrown if the system is unable to
connect to the given URL and download it to the local
machine.java.io.FileNotFoundException - This exception will be thrown if the given file does not
exist on the remote machien and therefore can not be
downloaded.java.io.IOException - This exception will be thrown if there is a general problem
downloading the given file.public int getSize()
public void setTimeout(java.lang.String timeout)
throws java.lang.NumberFormatException
timeout - This is the timeout in ms.java.lang.NumberFormatException - A number format exception will be thrown if the entry is
either not a string or is a negative number.public java.lang.String getTimeout()
public java.lang.String getContent()
public long getDownloadTime()
public int getPort()
public java.lang.String getHostname()
public boolean isUrlSet()