aspose file tools*
The moose likes Beginning Java and the fly likes exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "exceptions" Watch "exceptions" New topic
Author

exceptions

kiran nyala
Ranch Hand

Joined: Sep 21, 2009
Posts: 47

IS IT RETURNS -1 to main method??
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

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 ..


Thanks,
Sherif
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exceptions