I've had a really good look through other solutions. A number of variations that I can't wrap my head around.
package com.codegym.task.task18.task1820;
/*
Rounding numbers
*/
import java.io.*;
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.jar.JarOutputStream;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String filename1 = reader.readLine();
String filename2 = reader.readLine();
FileInputStream inputStream = new FileInputStream(filename1);
FileOutputStream outputStream = new FileOutputStream(filename2);
//FileInputStream inputStream = new FileInputStream("C:\\Users\\Angus\\Desktop\\Temp\\data.txt");
//FileOutputStream outputStream = new FileOutputStream("C:\\Users\\Angus\\Desktop\\Temp\\result.txt");
// convert inputStream to array
byte[] buffer = new byte[inputStream.available()];
inputStream.read(buffer);
// convert byte array to string
String str = new String(buffer);
// System.out.println(str);
// remove spaces from string and convert to array
String[] strArray = str.split(" ");
// Convert strArray values to doubles.
ArrayList<Byte> dubs = new ArrayList<>();
for (String s : strArray) {
dubs.add((byte) Math.round(Double.parseDouble(s)));
}
// convert arraylist to byte array for writing to file.
byte[] b = dubs.toString().getBytes();
outputStream.write(b);
reader.close();
inputStream.close();
outputStream.close();
}
}