Created
July 8, 2016 17:21
-
-
Save josinSbazin/7fc83ec18d68ebfa1528c1f48e9c3c96 to your computer and use it in GitHub Desktop.
level18.lesson05.task04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level18.lesson05.task04; | |
/* Реверс файла | |
Считать с консоли 2 имени файла: файл1, файл2. | |
Записать в файл2 все байты из файл1, но в обратном порядке | |
Закрыть потоки. Не использовать try-with-resources | |
*/ | |
import java.io.*; | |
public class Solution { | |
public static void main(String[] args) throws IOException { | |
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
String path1 = reader.readLine(); | |
String path2 = reader.readLine(); | |
reader.close(); | |
FileInputStream fileInputStream = new FileInputStream(path1); | |
if (fileInputStream.available()<=0) return; | |
byte[] buffer = new byte[fileInputStream.available()]; | |
fileInputStream.read(buffer); | |
fileInputStream.close(); | |
FileOutputStream fileOutputStream = new FileOutputStream(path2); | |
for (int i = buffer.length-1; i >=0; i--) fileOutputStream.write(buffer[i]); | |
fileOutputStream.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment