Been going over this one a bit, trying different things. Can't seem to figure it out. I checked other recent help questions but my code doesn't have exact same problem that the code in the other questions has.
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 = reader.readLine();
String destinationFileName = reader.readLine();
InputStream fileInputStream;
try
{
fileInputStream = getInputStream(sourceFileName);
}
catch(IOException e)
{
System.out.println("File does not exist.");
sourceFileName = reader.readLine();
fileInputStream = getInputStream(sourceFileName);
}
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);
}
}