Добрый день. Не прохожу по 3-му пункту. Почему? Вроде бы буфер с байтами реверсирую в отдельном методе, потом из изменённого reverseBuffer пишу в output. Где же ошибка?
package com.javarush.task.task18.task1809;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
Реверс файла
*/
public class Solution {
public static void main(String[] args) throws IOException {
try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileInputStream input = new FileInputStream(reader.readLine());
FileOutputStream output = new FileOutputStream(reader.readLine())) {
if (input.available() > 0) {
byte[] buffer = new byte[input.available()];
byte[] reverseBuffer = Solution.reverse(buffer);
while (input.available() > 0) {
int real = input.read(reverseBuffer);
output.write(reverseBuffer, 0, real);
}
}
}
}
public static byte[] reverse(byte[] array) {
byte[] resultArray = new byte[array.length];
for (int i = array.length - 1; i >= 0; i--) {
resultArray[array.length - i - 1] = array[i];
}
return resultArray;
}
}