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