Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.task.task09.task0929;
- import java.io.*;
- /*
- Обогатим код функциональностью!
- */
- public class Solution {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String sourceFileName;
- InputStream fileInputStream;
- while(true){
- try {
- sourceFileName = reader.readLine();
- fileInputStream = getInputStream(sourceFileName);
- break;
- }
- catch (FileNotFoundException e) {
- System.out.println("Файл не существует.");
- }
- }
- String destinationFileName = reader.readLine();
- OutputStream fileOutputStream = getOutputStream(destinationFileName);
- while (fileInputStream.available() > 0) {
- int data = fileInputStream.read();
- fileOutputStream.write(data);
- }
- fileInputStream.close();
- fileOutputStream.close();
- }
- public static InputStream getInputStream(String fileName) throws IOException {
- return new FileInputStream(fileName);
- }
- public static OutputStream getOutputStream(String fileName) throws IOException {
- return new FileOutputStream(fileName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement