Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Exp11_St_1_2:

import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class Exp11_StudAct_1_2 extends Frame implements ActionListener
{
Button b1;
TextArea ta;
TextField t1;
public Exp11_StudAct_1_2()
{ ta=new TextArea();
t1=new TextField(20);
Panel p1=new Panel();
b1=new Button("Submit");
b1.addActionListener(this);
p1.add(t1);
p1.add(b1);
add(ta,BorderLayout.CENTER);
add(p1,BorderLayout.SOUTH);
setSize(300,500);
setVisible(true);
}
public static void main(String[] args)
{
new Exp11_StudAct_1_2();
}

public void actionPerformed(ActionEvent arg0)


{
try
{
URL url = new URL(t1.getText().trim());

InputStream uin = url.openStream();


BufferedReader in = new BufferedReader(new
InputStreamReader(uin));
String line;
while ((line = in.readLine()) != null)
{
ta.setText(ta.getText()+"\n"+line);
}
in.close();
}
catch(IOException x){}
}
}
Output:

Exp11_St1: Exp11_St2:

You might also like