В своем решении я использовал конструкцию try with resources.
Почему валидатор не пропускает решение по 5му пункту?
Если возможно, то хотелось бы получить развернутый ответ как по самому решению, так и по вопросу.
package com.javarush.task.task13.task1326;
import java.io.*;
import java.nio.file.Files;
import java.util.*;
/*
Сортировка четных чисел из файла
*/
public class Solution
{
public static void main(String[] args)
{
String sourceStr;
try (Scanner input = new Scanner(System.in))
{
sourceStr = input.nextLine();
} catch (NoSuchElementException e)
{
e.printStackTrace();
return;
}
File sourceFile = new File(sourceStr);
if (!sourceFile.exists())
return;
List<Integer> integers = new ArrayList<>();
try (InputStream inputStream = new FileInputStream(sourceFile);
Scanner scanner = new Scanner(inputStream))
{
while (scanner.hasNextInt())
{
integers.add(scanner.nextInt());
}
} catch (IOException e)
{
e.printStackTrace();
return;
}
integers.stream().filter(e -> ((e % 2) == 0)).sorted().forEach(System.out::println);
}
}