//****************************************************************************** 
// ----------------------------------------------------------- 
// tipsFile1.java                                              
// ----------------------------------------------------------- 
// Comments : very simple text File applet JDK 1.02 version 
// ----------------------------------------------------------- 
// Author : R. BERTHOU 
// E-Mail : rbl@berthou.com 
// URL    : http://www.javaside.com 
// ----------------------------------------------------------- 
// 1.00 * R.BERTHOU  * 09/04/2000 * samples tips 
//****************************************************************************** 

 // Importations 
 import java.awt.* ; 
  
 import java.io.InputStream ; 
 import java.io.DataInputStream ; 
 import java.net.URL ; 

 public class tipsFile1 extends java.applet.Applet { 
     // Variables 
      String s ; 
      TextArea t1 = new TextArea("") ; 

     // Initialisation de l'applet 
     public void init() {  
          setLayout(new GridLayout(1,1)) ;   // Define a Layout 
          add(t1) ;                               // add TextArea 

        readFile("tipsFile1.java") ;         // read a file (this source code) 
            
          t1.setText(s) ;                              // Put text in a TextArea 
     } 

     // readFile 
     public void readFile(String f) { 
          s = new String("") ; 

          // Define InputStream 
          DataInputStream fis = null ; 

          // Open Stream 
          try { 
               URL u = new URL( getCodeBase(), f ) ; 
               fis = new DataInputStream( u.openStream() ) ; 
          } catch( Exception e ) { 
               s = "readFile : " + f + "\r\n --> Exception : " + e ; 
               return ; 
          } 

          String sS = new String("") ; 
           // read loop 
          while ( true ) { 
               try { 
                    sS = fis.readLine() ; 
                    if (sS != null) 
                         s = s + "\r\n" + sS ; 
                    else  
                         break ; // end of file 
               } catch( Exception e ) { 
                         break ; 
               }     
           } 
     } 
  } 

Generated by srcColor