I guess I did not understand the conditions properly.
I have tried different permutation and combinations, but it fails to fulfill the third condition.
package com.codegym.task.task09.task0929;
import java.io.*;
/*
Let's make the code do something useful!
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String sourceFileName = "";
String destinationFileName = reader.readLine();
InputStream fileInputStream = null;
int count = 0;
while(count < 2) {
try {
sourceFileName = reader.readLine();
fileInputStream = getInputStream(sourceFileName);
count = 2;
} catch(FileNotFoundException e) {
System.out.println("File does not exist.");
count++;
}
}
OutputStream fileOutputStream = getOutputStream(destinationFileName);
try {
while (fileInputStream.available() > 0) {
int data = fileInputStream.read();
fileOutputStream.write(data);
fileInputStream.close();
}
} catch(Exception e) {
//Some exceptions...
}
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);
}
}