Create a simple java program that reads all the content in a .txt file, the user will enter the filename to be opened and once opened with any stream of choice, all the content in the file is printed to the screen. You are additionally expected to deal most common exceptions(See samples below) [HINT: DO NOT PROVIDE A PATH BUT RATHER ONLY OPEN THE FILE WITH RELATIVE PATH/FILENAME
Create a simple java program that reads all the content in a .txt file, the user will enter the filename to be opened and once opened with any stream of choice, all the content in the file is printed to the screen. You are additionally expected to deal most common exceptions(See samples below)
[HINT: DO NOT PROVIDE A PATH BUT RATHER ONLY OPEN THE FILE WITH RELATIVE PATH/FILENAME]
Sample run 1:
Enter filename: input.txt
sample output 1:
Hello files, I got the content
NB: input.txt contains "Hello files, I got the content" as the data [See sample file]
Sample run 2:
Enter filename: myText.txt
sample output 2:
Invalid file : myText.txt could not be found in the current directory
NB: myText.txt is not a valid file
Requested files
InClassDemo.java
input.txt
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images