import java.io.InputStream; import java.io.IOException; import java.io.FileInputStream; import java.io.StringBufferInputStream; // deprecated in recent Java public class CountBytes { public static void main( String[] args ) throws IOException { // creating up the input stream -- change here InputStream dataSource; if ( args.length == 0 ) dataSource = System.in; else dataSource = new LowerCaseInputStream( new StringBufferInputStream(args[0]) ); // the main processing code -- no changes int totalCharacters = 0; while ( dataSource.read() != -1 ) totalCharacters++; System.out.println( "" + totalCharacters + " bytes" ); } }