Showing posts with label scrap. Show all posts
Showing posts with label scrap. Show all posts

Wednesday, November 4, 2009

Read data from web page

Let us look at sample code for reading data from a given url

//
// Create an url object
URL url = new URL("http://www.someUrl.com");
//
// Open connection to the url
URLConnection conn= url.openConnection();
//
// Open input stream to read
BufferedReader in = new BufferedReader(
new InputStreamReader(
conn.getInputStream()));
//
// read the content
String inputLine = null;
while ((inputLine = in.readLine()) != null) {
//
// Do something with inputLine .
}