im insert input
C:\new22.txt
C:\new11.txt
exit exception filenotfound
insert try catch - write no variable
please help
package com.codegym.task.task09.task0928;
import java.io.*;
/*
The code won't compile…
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try{
String sourceFileName = reader.readLine();
String destinationFileName = reader.readLine();
}
catch(FileNotFoundException e){
String sourceFileName = (new File("new22.txt")).getAbsolutePath();
String destinationFileName = (new File("new11.txt")).getAbsolutePath();
}
InputStream fileInputStream = getInputStream(sourceFileName);
OutputStream fileOutputStream = getOutputStream(destinationFileName);
int count = 0;
while (fileInputStream.available() > 0)
{
int data = fileInputStream.read();
fileOutputStream.write(data);
count++;
}
System.out.println("Bytes copied: " + count);
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);
}
}