Задача: "The Java Programming Language" Ken Arnold, James Gosling, David Holmes листинги, код, примеры из книги, исходники
Исходник: Глава 15, Ввод-Вывод (Chapter 15. Input-Output), CountByte class, язык: java [code #171, hits: 7252]
автор: - [добавлен: 12.09.2006]
  1. /**
  2. * Created by IntelliJ IDEA.
  3. * User: me
  4. * Date: 12.09.2006
  5. * Time: 17:09:20
  6. * To change this template use File | Settings | File Templates.
  7. */
  8. import java.io.*;
  9. public class CountBytes {
  10. public static void main(String[] args)
  11. throws IOException {
  12. if (args.length == 0)
  13. in = System.in;
  14. else
  15. in = new FileInputStream(args[0]);
  16.  
  17. int total = 0;
  18. while (in.read() != -1)
  19. total++;
  20.  
  21. System.out.println(total + " bytes");
  22. }
  23. }
  24.  
Тестировалось на: java 1.5.0_04

+добавить реализацию