Java Reference
In-Depth Information
public void checkURL(URL url) throws IOException
{
int ch;
StringBuilder sentence = new StringBuilder();
URLConnection http = url.openConnection();
http.setConnectTimeout(1000);
http.setReadTimeout(1000);
InputStream is = http.getInputStream();
ParseHTML html = new ParseHTML(is);
do
{
ch = html.read();
if ((ch != -1) && (ch != 0))
{
if (ch == '.')
{
String str = sentence.toString();
int year = extractBirth(str);
if ((year > 1) && (year < 3000))
{
System.out.println("URL supports year: " + year);
increaseYear(year);
}
sentence.setLength(0);
} else
sentence.append((char) ch);
}
} while (ch != -1);
}
/**
* Get birth year that occurred the largest number of times.
*
* @return The birth year that occurred the largest
* number of times.
*/
public int getResult()
{
int result = -1;
int maxCount = 0;
Set<Integer> set = results.keySet();
for (int year : set)
Search WWH ::




Custom Search