Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.test.level18.lesson10.home01;
- /* Английские буквы
- В метод main первым параметром приходит имя файла.
- Посчитать количество букв английского алфавита, которое есть в этом файле.
- Вывести на экран число (количество букв)
- Закрыть потоки. Не использовать try-with-resources
- */
- import java.io.FileInputStream;
- import java.io.IOException;
- public class Solution {
- public static void main(String[] args) throws IOException {
- FileInputStream fileInputStream = new FileInputStream(args[0]);
- char tempChar;
- int counter = 0;
- while (fileInputStream.available()>0) {
- tempChar = (char)fileInputStream.read();
- if ((tempChar >= 'a' && tempChar <= 'z') || (tempChar >= 'A' && tempChar <= 'Z')) {
- counter++;
- }
- }
- System.out.println(counter);
- fileInputStream.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement