For some reason, I am not able to write the integers to the file. Rounded them and try to convert them to byte before writing them on the file
package com.codegym.task.task18.task1820;
/*
Rounding numbers
*/
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String file1 = bufferedReader.readLine();
String file2 = bufferedReader.readLine();
ArrayList<Double> arrayList = new ArrayList<>();
FileInputStream inputStream = new FileInputStream(file1);
FileOutputStream outputStream = new FileOutputStream(file2);
byte[] list = new byte[inputStream.available()];
ArrayList< Integer> arrayList1 = new ArrayList<>();
if(inputStream.available() > 0){
int read = inputStream.read(list);
String str = new String(list,StandardCharsets.UTF_8);
String [] expected = str.split(" ");
for(String x : expected){
arrayList.add(Double.parseDouble(x));
}
for(int i = 0; i < arrayList.size();i++){
arrayList1.add(arrayList.get(i).intValue());
}
for(int j = 0;j <arrayList1.size();j++){
outputStream.write(arrayList1.get(j).byteValue());
//System.out.println(arrayList1.get(j));
}
}
inputStream.close();
outputStream.close();
}
}