Android : how to extract webpage links in eclipse

on Sunday, April 19, 2015


i want to extract all links of special webpage i try this:



URL url;
InputStream is = null;
BufferedReader br;
String line;
try {
url = new URL("http://www.stackoverflow.com");
is = url.openStream(); // throws an IOException
br = new BufferedReader(new InputStreamReader(is));

while ((line = br.readLine()) != null) {
if(line.contains("href="))
t1.setText(t1.getText()+line.trim());
}
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (is != null) is.close();
} catch (IOException ioe) {
//exception
}
}


but it doesnt do anything... please help me if you have otherway please help


0 comments:

Post a Comment