Could you help where am I making the mistake.. i did not use byte[] buffer as that is another approach. But is there a way to correct the one I wrote?
package com.codegym.task.task18.task1818;
/*
Two in one
*/
import java.io.*;
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();
String fileName3 = reader.readLine();
FileOutputStream outputStream1 = new FileOutputStream(fileName1);
FileInputStream inputStream2 = new FileInputStream(fileName2);
FileInputStream inputStream3 = new FileInputStream(fileName3);
while(inputStream2.available() > 0) {
outputStream1.write(inputStream2.read());
}
String dataFrom3 = "";
while(inputStream3.available() > 0) {
dataFrom3 += inputStream3.read();
}
outputStream1.write(dataFrom3.getBytes());
outputStream1.close();
inputStream2.close();
inputStream3.close();
}
}