2010-03-12

Piece of code to get the text content in a web file to an Android application.

// Make the connection
URL url = new URL(type_url_here_as_a_string);
URLConnection con = url.openConnection();
// Get the response
InputStreamReader isr = new InputStreamReader(con.getInputStream());
BufferedReader rd = new BufferedReader(isr);
if(rd.ready()){ //Check the buffer reader ready for read.
    //Perform the read here by using rd.read() or rd.readLine() according to your requirement.
}
rd.close(); //Close the Buffer Reader.

1 comment:

Orchids said...

All Sri Lankan Bloggers invited to join the
one and only Multi lingual
DIRECTORY OF SRI LANKAN BLOGGERS
Orchids
http://www.orchidslk.co.nr/