This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Error while reading text files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error while reading text files" Watch "Error while reading text files" New topic

Error while reading text files

Ryan Falzon

Joined: May 22, 2012
Posts: 1
I am currantly having a problem with text files...

// Method to calculate the sum of the marks entered by the user

... I canot to seem to find the problem. When I run the application it gives me the error i created "Error Occured While\nReading Text File".
can anyone help me please ???
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38467
Welcome to the Ranch

I have split this post from an old thread because it didn’t fit the previous subject.
You cannot tell what is happening because the cath block does not display the full details. You cannot tell what sort of Exception is happening, nor why. It is generally a bad idea to catch plain simple Exception. You should catch more specific Exceptions; for example the code you are using might throw IOException or FileNotFoundException. I would suggest replace the catch with the following code:Then you can see what sort of Exception is happening. When you have that knowledge, you can start working out what is happening. Please show us the stack traces.
It is sorta covered in the JavaRanch Style Guide.
subject: Error while reading text files