import java.net.*; import java.awt.*; import java.io.*; import java.applet.*; public class Tekstilugeja extends Applet{ TextArea ta=new TextArea(); URL aadress; public void init(){ try{ setLayout(new BorderLayout()); add("Center", ta); ta.setText("kuku"); String failinimi=getParameter("failinimi"); aadress=new URL(getDocumentBase(), failinimi); System.out.println(aadress); BufferedReader sisse = new BufferedReader( new InputStreamReader( aadress.openConnection(). getInputStream() ) ); String rida=sisse.readLine(); StringBuffer sb=new StringBuffer(); int ridadearv=0; while(rida!=null){ sb.append(rida+"\n"); rida=sisse.readLine(); ridadearv++; } ta.setFont(new Font("Courier", Font.PLAIN, (ridadearv>20)?12:12)); ta.setEditable(false); ta.setText(sb.toString()); }catch(IOException ioe){ ta.setText("Probleem ühendusega: "+aadress+"\n" + ioe.getMessage()); }catch(Exception e){ ta.setText("Probleem:" + e.getMessage()); } } }