Не пойму в чем ошибка? В файл все записывается правильно.
package com.javarush.task.task18.task1820;
/*
Округление чисел
*/
import java.io.*;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String firstFileName = reader.readLine();
String secondFileName = reader.readLine();
reader.close();
FileInputStream inputStream = new FileInputStream(firstFileName);
BufferedInputStream bf = new BufferedInputStream(inputStream);
byte[] bytes = new byte[bf.available()];
bf.read(bytes);
bf.close();
String[] strings = new String(bytes).split(" ");
StringBuilder stringBuilder = new StringBuilder();
for (String s: strings) {
stringBuilder.append(doubleToInt(s) + " ");
}
FileOutputStream outputStream = new FileOutputStream(secondFileName);
outputStream.write(stringBuilder.toString().getBytes());
outputStream.close();
}
public static int doubleToInt(String s) {
double d = Double.parseDouble(s);
int x = 0;
if (d < 0) {
if (d % (int)d >= -0.5) {
x = (int)d;
} else x = (int) (d-1);
} else if (d >= 0) {
if (d % (int)d < 0.5) {
x = (int)d;
} else x = (int) (d+1);
}
return x;
}
}