Проверял на разных текстах и результат, кажется, верный выводит, но валидатор не принимает. Помогите понять что я сделал не так.
package com.javarush.task.task18.task1817;
/*
Пробелы
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws IOException {
//FileInputStream fileInputStream = new FileInputStream("C:\\Users\\Женя\\Desktop\\Java1.txt");
FileInputStream fileInputStream = new FileInputStream(args[0]);
BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream));
int countSpace = 0, countAll = 0;
String line = "";
while ((line = reader.readLine()) != null) {
countAll += line.length();
countSpace += line.length() - line.replaceAll(" ", "").length();
}
try {
System.out.println(Math.round(((double) countAll/countSpace)*100.0)/100.0);
}
catch (ArithmeticException e) {
System.out.println(e.getClass().getSimpleName());
}
fileInputStream.close();
reader.close();
}
}