• 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: 21190
80
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: 20546
56
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