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 >
Wrap
Text File
|
1996-09-28
|
790b
|
29 lines
import java.io.*;
class CountFile {
public static void main ( String args[] )
throws java.io.IOException,
java.io.FileNotFoundException
{
int count = 0 ;
int tmp = 0 ;
InputStream is;
byte[] buffer = new byte[1024] ;
if ( args.length == 1 ) {
is = new FileInputStream(args[0]) ;
} else {
is = System.in ;
}
while ( ( tmp = is.read(buffer) ) != -1 ) {
count += tmp ;
System.out.println( "Read " + tmp + " chars" ) ;
}
System.out.println ( "Input has " + count + " chars" ) ;
}
}