I tried many different designs. Nothing worked for this last check. Can anybody give me a hint?
Greatly appreciated :D
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 {
int count = 0;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String sourceFileName = reader.readLine();
String destinationFileName = reader.readLine();
InputStream fileInputStream = getInputStream(sourceFileName);
OutputStream fileOutputStream = getOutputStream(destinationFileName);
while (fileInputStream.available() > 0) {
System.out.println("test");
int data = fileInputStream.read();
fileOutputStream.write(data);
count++;
}
fileInputStream.close();
fileOutputStream.close();
} catch (IOException e){
System.out.println("IOException!");
} finally {
System.out.println("Bytes copied: " + count);
}
}
public static InputStream getInputStream(String fileName) throws IOException {
return new FileInputStream(fileName);
}
public static OutputStream getOutputStream(String fileName) throws IOException {
return new FileOutputStream(fileName);
}
}