Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. package com.javarush.task.task09.task0929;
  2.  
  3. import java.io.*;
  4.  
  5. /*
  6. Обогатим код функциональностью!
  7. */
  8.  
  9. public class Solution {
  10. public static void main(String[] args) throws IOException {
  11. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  12.  
  13. String sourceFileName;
  14. InputStream fileInputStream;
  15.  
  16. while(true){
  17. try {
  18. sourceFileName = reader.readLine();
  19. fileInputStream = getInputStream(sourceFileName);
  20. break;
  21. }
  22. catch (FileNotFoundException e) {
  23. System.out.println("Файл не существует.");
  24. }
  25. }
  26.  
  27.  
  28. String destinationFileName = reader.readLine();
  29. OutputStream fileOutputStream = getOutputStream(destinationFileName);
  30.  
  31. while (fileInputStream.available() > 0) {
  32. int data = fileInputStream.read();
  33. fileOutputStream.write(data);
  34. }
  35.  
  36. fileInputStream.close();
  37. fileOutputStream.close();
  38. }
  39.  
  40. public static InputStream getInputStream(String fileName) throws IOException {
  41. return new FileInputStream(fileName);
  42. }
  43.  
  44. public static OutputStream getOutputStream(String fileName) throws IOException {
  45. return new FileOutputStream(fileName);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement