Java Reference
In-Depth Information
http.setConnectTimeout(100);
InputStream s = http.getInputStream();
int size = 0;
do
{
size = s.read(buffer);
if (size != -1)
result.append(new String(buffer, 0, size));
} while (size != -1);
return result.toString();
}
/**
* Extract a string of text from between the two specified
* tokens. The case of the two tokens need not 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 extractNoCase(String str, String token1,
String token2,
int count)
{
int location1, location2;
// convert everything to lower case
String searchStr = str.toLowerCase();
token1 = token1.toLowerCase();
token2 = token2.toLowerCase();
// now search
location1 = location2 = 0;
do
{
location1 = searchStr.indexOf(token1, location1 + 1);
Search WWH ::




Custom Search