Java Reference
In-Depth Information
{
boolean foundBorn = false;
int result = -1;
StringTokenizer tok = new StringTokenizer(sentence);
while (tok.hasMoreTokens())
{
String word = tok.nextToken();
try
{
result = Integer.parseInt(word);
} catch (NumberFormatException e)
{
if (word.equalsIgnoreCase("born"))
foundBorn = true;
}
}
if (!foundBorn)
result = -1;
return result;
}
/**
* Increase the specified year's count in the map.
* @param year The year to increase.
*/
private void increaseYear(int year)
{
Integer count = results.get(year);
if (count == null)
count = new Integer(1);
else
count = new Integer(count.intValue() + 1);
results.put(year, count);
}
/**
* Check the specified URL for a birth year. This will occur
* if one sentence is found that has the word born, and a
* numeric value less than 3000.
*
* @param url The URL to check.
* @throws IOException Thrown if a communication error occurs.
*/
Search WWH ::




Custom Search