Fetching a Webpage using Java

This is a simple java code to fetch a webpage.

public class Test {

public static void main(String[] args) {
 URL url;
 InputStream is = null;
 BufferedReader br;
 String line;

try {
 url = new URL("http://www.wikipedia.org/");
 is = url.openStream(); // throws an IOException
 br = new BufferedReader(new InputStreamReader(is));

while ((line = br.readLine()) != null) {
 } catch (MalformedURLException mue) {
 } catch (IOException ioe) {
 } finally {
 try {
 } catch (IOException ioe) {
 // nothing to see here

About amalgjose
I am an Electrical Engineer by qualification, now I am working as a Software Architect. I am very much interested in Electrical, Electronics, Mechanical and now in Software fields. I like exploring things in these fields. I love travelling, long drives and music.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: