I tried multiple solutions for 1 hr and didn't work with any of those
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;
InputStream fileInputStream = null;
int i = 0;
try {
sourceFileName = reader.readLine();
fileInputStream = getInputStream(sourceFileName);
i++;
} catch (Exception e){
System.out.println("File does not exit.");
}
if (i == 0){
try {
sourceFileName = reader.readLine();
fileInputStream = getInputStream(sourceFileName);
i++;
} catch (Exception e){
System.out.println("File does not exit.");
}
}
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);
}
}
exit." it should be "exist"