Java Tutorial

 
 
 
 
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();
    }

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

    public void 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);
        }
    }
}

    Related Post:
  1. An applet program to take user input and display

  2. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  3. Do the following for the Array Insert the element in the array,delete an element from the array,search for a particular element Create multiple thread

  4. Corba program of date operations

  5. Program of reading and writing primitive data

  6. Program to show an example of Multiple Levels of Inheritance

  7. An applet program to display Horizontal Color Bar

  8. Program to show an example of extraction of characters from a StringBuffer objects

  9. Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server

  10. Program that reads and writes random access file

  11. Program to show the use of For Loop

  12. An applet program to perform quick sort

  13. Program to show an example of using a recursive method in a class

  14. Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

  15. An applet program to display barchart of given data

  16. Program to show an example of getting at characters in a String

  17. Program to show an example of using a Non-Static Nested Class

  18. Program to show insertion of StringBuffer, String objects and other Basic Data Types into a StringBuffer object

  19. Program to show an example of using Abstract Class and Abstract Method

  20. Program to display Floyds Triangle of a numbers

 
 
Didn't find what you were looking for? Find more on CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL