1. import java.io.*;
2.
3. public class CountFile2
4. {
5. int count=0;
6. public void countChars() throws Exception
7. {
8. FileInputStream fis =
9. new FileInputStream("C:\\AUTOEXEC.BAT");
10. try
11. {
12. while (fis.read() != -1)
13. count++;
14. System.out.println("We counted " + count + " chars.");
15. }
16. catch (Exception e)
17. {
18. System.out.println("No characters counted");
19. System.out.println("Exception caught" + e.toString());
20. }
21. }
22. }