Java Reference
In-Depth Information
} while (size != -1);
return result.toString();
}
/**
* Extract a string of text from between the two specified
* tokens. The case of the two tokens must match.
*
* @param url The URL to download.
* @param token1 The text, or tag, that comes before the
* desired text.
* @param token2 The text, or tag, that comes after the
* desired text.
* @param count Which occurrence of token1 to use, 1 for
* the first.
* @return The contents of the URL that was downloaded.
*/
public String extract(String str, String token1,
String token2, int count)
{
int location1, location2;
location1 = location2 = 0;
do
{
location1 = str.indexOf(token1, location1 + 1);
if (location1 == -1)
return null;
count--;
} while (count > 0);
location2 = str.indexOf(token2, location1 + 1);
if (location2 == -1)
return null;
return str.substring(location1 + token1.length(), location2);
}
/**
* Get the time for the specified city.
*/
public Date getCityTime(int city) throws IOException,
ParseException
Search WWH ::




Custom Search