This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exceptions

 
kiran nyala
Ranch Hand
Posts: 52
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IS IT RETURNS -1 to main method??
 
Henry Wong
author
Marshal
Pie
Posts: 20894
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kiran nyala wrote:
IS IT RETURNS -1 to main method??


Why don't you tell us. When you run the program, does the method return -1?

BTW, there are easier ways to detect if a file exists -- have you looked into some of the methods of the java.io.File class?

Henry
 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kiran nyala wrote:IS IT RETURNS -1 to main method??

The best way to learn is to try things by yourself ,
for me it will not return -1 , and will give you this exception because there is no return type for the method "readFile()" it suppose to return int , to solve this , move the return statement after the finally clause ..
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or in the try body. It will then return something if the try body throws an exception and when it doesn't. Now it only returns something if it does.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic