home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / kaffe-0.5p4-src.tgz / tar.out / contrib / kaffe / test / file / CountFile.java next >
Text File  |  1996-09-28  |  790b  |  29 lines

  1. import java.io.*;
  2.  
  3. class CountFile {
  4.  
  5.         public static void main ( String args[] )
  6.         throws  java.io.IOException,
  7.                 java.io.FileNotFoundException
  8.         {
  9.  
  10.                 int count = 0 ;
  11.                 int tmp = 0 ;
  12.                 InputStream is;
  13.                 byte[]  buffer = new byte[1024] ;
  14.  
  15.                 if ( args.length == 1 ) {
  16.                         is = new FileInputStream(args[0]) ;
  17.                 } else {
  18.                         is = System.in ;
  19.                 }
  20.  
  21.                 while ( ( tmp = is.read(buffer) ) != -1 ) {
  22.                         count += tmp ;
  23.                         System.out.println( "Read " + tmp + " chars" ) ;
  24.                 }
  25.  
  26.                 System.out.println ( "Input has " + count + " chars" ) ;
  27.         }
  28. }
  29.