This week's book giveaway is in the Cloud/Virtualization forum. We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line! See this thread for details.
I am trying to create a program that reads from an input file specified by the user and writes to a file by a name that is specified by the user.
The program reads from an input file containing integer numbers that represent Fahrenheit temperatures and then converts these to their equivalent Celsius temperatures, and writes them to the output file.
I am using Eclipse so I placed the .txt file in the Project Folder aka the folder where SRC and BIN folders reside in.
So, my main problem is that my program does not get to the part of reading/writing to the files, it just collects user data and then throws an exception (It compiles).
Matt Hazan wrote:Okay, so I copied and pasted the exception details:
The exception there points to line 34 in your code, which (as Marc notes) does not correspond to the source code you posted at the top. Using my psychic abilities, I think it matches to line 23 in the code you posted.
It would appear that when looking at the string inputFileName, the Scanner cannot find a number. Given that inputFileName probably contains something like "input.txt", I would agree that it is probably not a number. (For fun, you could tell it that your input file is "95" and see if the program works.