Hi,
I am using collections to reverse the order but it does not seem to work. Could you tell me what I am doing wrong.
Thanks,
Alex
package com.codegym.task.task18.task1809;
/*
Reversing a file
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Arrays;
public class Solution {
public static void main(String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try{
String file1 = reader.readLine();
String file2 = reader.readLine();
FileInputStream inputStream = new FileInputStream(file1);
FileOutputStream outputStream = new FileOutputStream(file2);
byte[] fullData = new byte[inputStream.available()];
Collections.reverse(Arrays.asList(fullData));
outputStream.write(fullData);
inputStream.close();
outputStream.close();
}catch(Exception e){
e.printStackTrace();
}
}
}