#Reading a CSV file with a Scanner
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
avoid returning in a finally block
also please use a try-with-resources
show the error please
I can't screenshot the entire thing or copy it but does this help?
Like I don't know if that really helps
I changed it up but I'm still producing the same result
where is the file ?
IDoNotExist.csv 🤨
the name doesn't match 🤔
I'm srry for being unclear but this is what I am trying to solve specifically the second part
you shouldn't do that
if it can't find the file
you should throw, not catch
is there a reason it is better to do it as a throw and is something like this in the right direction?
If the file is not found, readTestResults won't be able to do anything about it
readTestResults can't recover from that problem. You should instead tell the person who specified the file that it was not found
You would only catch if
- You are able to recover from the issue
- You know 100% sure that the person calling the method won't be able to recover from the issue
@mild agate and @cedar barn thank you for helping me. It makes more sense to me now. Sorry for being unclear with my question.
please add a try-with-resources
and can this method fail ? like if you call, it, will it be a bug if it throw a FileNotFoundException ?
No worries. Did you solve your problem? Is it okay to close this thread?
I was able to yeah
Awesome, good to hear. Gonna close this thread, to keep the number of active threads low. Can re-open at any time by posting again