Change the TxtInputStream class so that it only works with txt files (* .txt).
For example, first.txt or name.1.part3.txt.
If a non-txt file is passed (e.g. file.txt.exe), then the constructor should throw an UnsupportedFileNameException.
Think about what else you need to do if an exception is throw
UnsupportedFileName
- 10
Locked
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Mike S
7 February, 18:34
I passed the exercise, but what I wanted to do was something like this:
Obviously, it wouldn't let me do that since the super() wasn't in the first line. But creating a new instance of FileInputStream seemed off too. Why is that happening in the constructor? That seems one step beyond what the exercise was asking. I feel like there's something intuitive that I'm missing here... 0
DarthGizka
6 June 2021, 16:05
task1814 (UnsupportedFileName) CAVEAT: when the requirements say 'you must also call super.close()' then you have to take that literally (that is, you need to specify the superfluous 'super.' prefix, even though 'close()' without the prefix is exactly the same thing in this case). Perhaps someone should send the programmer who is responsible for this on a Java course for beginners...
0
Switch/Cypher
5 October 2020, 18:10
Knowing about
x.endsWith(String)
might have helped.....
+3