3 и 4 пункты
package com.javarush.task.task18.task1821;
/*
Встречаемость символов
*/
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
FileInputStream inputStream = new FileInputStream(args[0]);
HashMap<Integer, Integer> map = new HashMap<>();
HashSet<Integer> set = new HashSet<>();
ArrayList<Integer> list= new ArrayList<>();
ArrayList<Integer> list1= new ArrayList<>();
int repeat =0;
while (inputStream.available() >0) {
int i = inputStream.read();
if (i > 64 && i < 91 || i > 96 && i < 123) {
list.add(i);
set.add(i);
}
}
for (int value: set)
{
for (int j=0; j<list.size(); j++)
{
if(value==list.get(j))
{
repeat++;
map.put(value,repeat);
}
repeat = 0;
}
}
for(Map.Entry<Integer,Integer> pair: map.entrySet())
{
for (int i = 65; i < 91; i++)
{
if (pair.getKey().equals(i))
{
int a = (int) pair.getKey();
char b = (char) a;
System.out.println(b + " " + pair.getValue());
}
}
for (int i = 97; i < 123; i++)
{
if (pair.getKey().equals(i))
{
int a = (int) pair.getKey();
char b = (char) a;
System.out.println(b + " " + pair.getValue());
}
}
}
inputStream.close();
}
}