Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.test.level18.lesson05.task03;
- /* Разделение файла
- Считать с консоли три имени файла: файл1, файл2, файл3.
- Разделить файл1 по следующему критерию:
- Первую половину байт записать в файл2, вторую половину байт записать в файл3.
- Если в файл1 количество байт нечетное, то файл2 должен содержать бОльшую часть.
- Закрыть потоки ввода-вывода
- */
- import java.io.*;
- public class Solution {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- FileInputStream in = new FileInputStream(new File(reader.readLine()));
- FileOutputStream out = new FileOutputStream(reader.readLine());
- FileOutputStream out1 = new FileOutputStream(reader.readLine());
- int i = 0;
- while ( in.available() > 0){
- int data = in.read();
- i++;
- if(i%2 == 1)
- out.write(data);
- else
- out1.write(data);
- }
- in.close();
- out.close();
- out1.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement