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. Program using Switch case to compute the net amount to be paid by a customer

  2. Corba program to encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time.

  3. Program which will read a string and rewrite it in the alphabetical order

  4. Program to find a factorial of a given number

  5. Program to show the use of Conditional (Ternary) Operator

  6. Program to show an example of creating Character Arrays from String objects

  7. Socket program of multi client chat server

  8. Program to show the use of Switch Statement for the same statement for several different case labels

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

  10. Program to copy the elements of an array into another array in reverse order and print them

  11. Develop a CORBA application that takes a string from client and returns whether it is palindrome

  12. Program to show the use of operator (>>) Shift Right, propagating the sign bit from the left

  13. Program to print some text on the same line using multiple print statements

  14. Program to show the use of Labeled Continue Statement

  15. Program to check the start and end of a String

  16. Program for Thread Priority

  17. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  18. Program of UDP news server

  19. 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

  20. Program to show an example of extracting subStrings from a String

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