Advertisement
jaVer404

level09.lesson11.bonus01

Apr 26th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. package com.javarush.test.level09.lesson11.bonus01;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6.  
  7. /* Нужно исправить программу, чтобы компилировалась и работала
  8. Задача: Программа вводит два имени файла. И копирует первый файл на место заданное вторым именем.
  9. */
  10.  
  11. public class Solution
  12. {
  13.     public static void main(String[] args) throws IOException
  14.     {
  15.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  16.  
  17.         String sourceFileName = reader.readLine();
  18.         String destinationFileName = reader.readLine();
  19.  
  20.         java.io.FileInputStream fileInputStream = new java.io.FileInputStream(sourceFileName);
  21.         java.io.FileOutputStream fileOutputStream = new java.io.FileOutputStream(destinationFileName);
  22.  
  23.         int count = 0;
  24.         while (fileInputStream.available()>0)
  25.         {
  26.             int data = fileInputStream.read();
  27.             fileOutputStream.write(data);
  28.             count++;
  29.         }
  30.  
  31.         System.out.println("Скопировано байт " + count);
  32.  
  33.         fileInputStream.close();
  34.         fileOutputStream.close();
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement