So my question is just how the title goes. Below is a snippet of my code. I understand that I’m supposed to use try/catch but in my catch, I’m not sure what to do in it. I’m getting an error /HERE/ saying that a BufferedReader cannot take in an InputStream. I want to continue using a BufferedReader, so is there any other class that I could instantiate w/in my new BufferedReader so that my compiler will be happy? Any help will be much appreciated, thank you!
//reads in 'dictionary' file
BufferedReader bReader;
try
{
bReader = new BufferedReader
(new FileReader("unsortedWords.txt"));
}
catch (FileNotFoundException e)
{
System.out.print("Enter name of dictionary file: ");
bReader = new BufferedReader
(new FileReader(System.in)); /*HERE*/
}
Maybe this:
If you are unsure how to do the command line or GUI thing then just ask me and I will post the rest of the code.
[EDIT]:
I see you are doing the command line, so you can try this:
[EDIT]: Sample Class (yes it has bad design, but I wrote it quickly):
[EDIT]:
Here is a class that I made which should work for you.
Screenshot: