Hi, whats the problem with my code ? thanks.
package com.codegym.task.task13.task1318;
/*
Reading a file
1. Read a file name from the console.
2. Display the contents of the file in the console (on the screen).
3. Don't forget to free up resources. Close the streams for file input and keyboard input.
Requirements:
1. The program must read the file name from the console.
2. The program must display the contents of the file.
3. You must close the file input stream (FileInputStream).
4. The BufferedReader must also be closed.
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
FileInputStream inStream = new FileInputStream(bufferedReader.readLine());
while (inStream.available() > 0) { //Continue Loop as long as FileInputStream is not at the end of the file
int data = inStream.read(); //Int variable data is equal to current byte in file
System.out.print(data);
}
inStream.close();
bufferedReader.close();
}
}