Skip to content

Instantly share code, notes, and snippets.

@ProZhar
Created December 6, 2015 11:26
Show Gist options
  • Select an option

  • Save ProZhar/81d1476b656607b65518 to your computer and use it in GitHub Desktop.

Select an option

Save ProZhar/81d1476b656607b65518 to your computer and use it in GitHub Desktop.
com.javarush.test.level09.lesson11.bonus01
package com.javarush.test.level09.lesson11.bonus01;
import java.io.*;
/* Нужно исправить программу, чтобы компилировалась и работала
Задача: Программа вводит два имени файла. И копирует первый файл на место заданное вторым именем.
*/
public class Solution
{
public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String sourceFileName = reader.readLine();
String destinationFileName = reader.readLine();
FileInputStream fileInputStream = new FileInputStream(sourceFileName);
FileOutputStream fileOutputStream = new FileOutputStream(destinationFileName);
int count = 0;
while (fileInputStream.available()>0)
{
int data = fileInputStream.read();
fileOutputStream.write(data);
count++;
}
System.out.println("Скопировано байт " + count);
fileInputStream.close();
fileOutputStream.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment