Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. public class Ihor {
  2.  
  3.     private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  4.  
  5.     public static void main(String[] args) throws IOException {
  6.         String sourceFileName = reader.readLine();
  7.         String destinationFileName = reader.readLine();
  8.  
  9.         InputStream inputStream = getInputStream2(sourceFileName);
  10.         OutputStream outputStream = getOutputStream(destinationFileName);
  11.  
  12.         while (inputStream.available() > 0) {
  13.             outputStream.write(inputStream.read());
  14.         }
  15.     }
  16.  
  17.     private static InputStream getInputStream2(String fileName) throws IOException {
  18.         try {
  19.             return getInputStream(fileName);
  20.         } catch (FileNotFoundException e) {
  21.             return getInputStream2(reader.readLine());
  22.         }
  23.     }
  24.  
  25.     private static InputStream getInputStream(String fileName) throws IOException {
  26.         return new FileInputStream(fileName);
  27.     }
  28.  
  29.     private static OutputStream getOutputStream(String fileName) throws IOException {
  30.         return new FileOutputStream(fileName);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement