import java.net.*; import java.io.*; import java.awt.*; import java.awt.event.*; import java.applet.Applet; import java.util.*; //----- Programm "Lingid" otsib ette antud -------- //----- aadressilt kõik lingid ja salvestab ------- //----- need html faili. Lõppu lisab veel --------- //----- kuupäeva millal fail loodi. --------------- public class Lingid extends Applet implements ActionListener{ Label url1=new Label("Aadress (URL)"); TextField tf1=new TextField("http://",50); Label nimi=new Label(" Salvesta faili- "); TextField tf2=new TextField("lingid.html",50); TextArea tf3=new TextArea("",11,65); Label tekst=new Label("© Veiko Somelar."); public Lingid(){ add(url1); add(tf1); add(nimi); add(tf2); add(tf3); add(tekst); tf3.setEditable(false); tf3.setBackground(Color.lightGray); tf1.addActionListener(this); tf2.addActionListener(this); } public void actionPerformed(ActionEvent ee){ tf3.setText(" "); char t; try{ String aadress=tf1.getText(); String fail=tf2.getText(); BufferedReader sisse=new BufferedReader( new InputStreamReader(new URL(aadress).openStream()) ); PrintWriter valja=new PrintWriter( new FileWriter(fail) ); valja.println("
");
valja.println("");
valja.println(new Date()+"
");
valja.println("© Veiko Somelar");
valja.println("");
valja.println("");
valja.close();
}catch (Exception e){}
}
public static void main(String argumendid[]) {
Frame f=new Frame("--Lingid--");
f.add(new Lingid());
f.setSize(500,300);
f.setBackground(Color.lightGray);
f.setVisible(true);
f.setResizable(false);
f.addWindowListener(new valjaq());
}
}
class valjaq extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}