import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.applet.Applet;

public class serverdosyaokuyucu extends Applet implements ActionListener
{
  private TextField gir;
  private TextArea icerik;

  public void init()
  {
  gir=new TextField("Dosya URL adresini buraya giriniz");
  gir.addActionListener(this);
  add(gir,BorderLayout.NORTH);
  icerik=new TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY);
  add(icerik,BorderLayout.CENTER);
  }

  public void actionPerformed(ActionEvent e)
  {
  URL url;
  BufferedReader oku;
  String satir;
  StringBuffer dokuman=new StringBuffer();
  String yer=e.getActionCommand();
  try {
      url=new URL(yer);
      oku=new BufferedReader(new InputStreamReader(url.openStream()));
      icerik.setText("Dosya okunuyor....");
      while((satir=oku.readLine())!=null)
        dokuman.append(satir).append('\n');
      icerik.setText(dokuman.toString());
      oku.close();
      }
      catch(MalformedURLException mal) {icerik.setText("Gecersiz URL formati");}
      catch(IOException io) {icerik.setText(io.toString());}
  }
}
