Ошибка: Учти, что файл может содержать целые числа.
Но я же проверяю содержит ли файл не дробные числа.
package com.javarush.task.task18.task1820;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/*
Округление чисел
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String file1 = reader.readLine();
String file2 = reader.readLine();
try (FileInputStream in = new FileInputStream(file1);
FileOutputStream out = new FileOutputStream(file2)) {
StringBuilder sb = new StringBuilder();
float f = 0;
while (in.available() > 0) {
int value = in.read();
sb.append((char) value);
}
String str = sb.toString();
String[] strings = str.split("\n");
for (String s : strings) {
if (!s.contains(".")) {
out.write(s.getBytes(StandardCharsets.UTF_8));
out.write("\n".getBytes(StandardCharsets.UTF_8));
} else {
f = Float.parseFloat(s);
out.write((Math.round(f) + "\n").getBytes(StandardCharsets.UTF_8));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}