Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » CorbaRSS Feeds

CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL

Posted By: Milind Mishra     Category: Java     Views: 5590

CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL.

Code for CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL in Java

import java.net.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

class HTMLGetter extends Frame implements ActionListener
{
    TextField tURL = new TextField(50);
    Button btn = new Button("Get HTML");
    Button exit = new Button("Exit");
    TextArea ta = new TextArea(50,20);

    HTMLGetter() throws Exception
    {
        Panel p = new Panel();
        add(p,BorderLayout.NORTH);
        p.add(tURL);
        p.add(btn);
        p.add(exit);
        add(ta);
        btn.addActionListener(this);
        exit.addActionListener(this);
        setSize(600,400);
        show();
    }

    publicstaticvoid main(String args[]) throws Exception
    {
        HTMLGetter hg = new HTMLGetter();
    }

    publicvoid actionPerformed(ActionEvent ae)
    {
        if(ae.getSource()==btn)
        {
            try
            {
                URL htmlURL = new URL(tURL.getText());
                InputStream in = htmlURL.openStream();
                BufferedReader br = new BufferedReader(new InputStreamReader(in));
                String getLine;

                while((getLine=br.readLine())!=null)
                {
                    ta.append(getLine);
                }
                br.close();
                in.close();
            }
            catch(Exception e)
            {
                //No handling exception here;
            }
        }
        else
        {
            System.exit(0);
        }
    }
}
  
Share: 


Didn't find what you were looking for? Find more on CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL Or get search suggestion and latest updates.

Milind Mishra
Milind Mishra author of CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL is from India.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!