/**
*Lihtne veebisirvija, millega heal juhul näeb ka midagi
*@autjor Herki Suöa
*@since JDK1.3
*/
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class BSR1{
public static void main(String argumendid[]) throws IOException{
final JFrame f=new JFrame("rama");
final JLabel silt1=new JLabel("See seal üleval on aadressiväli. "+
"Proovi mõnda weebileht vaadata");
final JTextField urli=new JTextField("http://");
silt1.setBackground(new Color(200,50,100));
f.setSize(800,600);
f.setTitle("BSR 1.0");
f.getContentPane().add(urli,BorderLayout.NORTH);
f.getContentPane().add(silt1,BorderLayout.CENTER);
f.setVisible(true);
urli.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try{
PrintWriter logi=new PrintWriter(
new FileWriter("logi.txt",true)
);
String aadress=urli.getText();
logi.println(aadress);
logi.close();
BufferedReader sisse=new BufferedReader(
new InputStreamReader(new URL(aadress).openStream())
);
String rida=sisse.readLine();
String html="";
while(rida!=null){
html=html+rida+"\n
";
rida=sisse.readLine();
}
html=html.substring(html.lastIndexOf(""),html.length());
silt1.setText(html);
}catch(Exception r){
silt1.setText("
."+ "\nProblem: "+r); } } }); f.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); } }