aspose file tools*
The moose likes I/O and Streams and the fly likes java.io.FileNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "java.io.FileNotFoundException" Watch "java.io.FileNotFoundException" New topic
Author

java.io.FileNotFoundException

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Hello,

I am getting java.io.FileNotFoundException


My DAO method:


Main method


The stackTrace is as follow:


Thanks in anticipation
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

The error message seems pretty clear to me: it says it can't find a file, and it gives you the full path of the file it can't find. So what is your question about that?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

If it can't find the file there are two possible reasons:
1) the file does not exist
2) you don't have access to read the file; either the file itself is not readable, or one of its parent directories is inaccessible


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732

Thanks for your reply

The properties of the directory is set to 755 is that not acessable?
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Farakh khan wrote:
Thanks for your reply

The properties of the directory is set to 755 is that not acessable?


That's rwxr-xr-x, which it read/write/execute for owner, and read and execute for group and others. Note that you have to check the permissions on every parent directory in the path and on the file itself.

What happens when you do


as the same user that's executing your Java code?
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Hello,

I made a new folder /home/bulkSavedCVs and given to both folders 777 but still getting the error. I believe something wrong is with my code particularly with renaming the file and then moving.....
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

Are you 100% certain the file name in your code also leads to an existing file; unlike Windows, UNIX/Linux file names are case sensitive and I see you're using a mix of cases; which is fine but makes it also very easy to make mistakes.
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
The folder names are in mix cases but the file names are dynamic and are passed as it is. My property file is taking the same name cases. I don't know where I am messing
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

Try Jeff's suggestion (the ls command) and copy/paste your results here.
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Thanks for all trying to help me

The problem was not folder permissions. I changed this piece of code:


to this:


and now its work fine

Thanks again & best regards
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Farakh khan wrote:Thanks for all trying to help me

The problem was not folder permissions. I changed this piece of code:




Glad you got it solved!

Do you understand why that code was wrong, and is in fact always pointless?
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
I declared success as false and then was coding if(success) then success=true. That was the blunder
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Farakh khan wrote:I declared success as false and then was coding if(success) then success=true. That was the blunder


Well, the point I was trying to make is that this code:


will always be useless, no matter what the situation, and no matter what value success has.

If success is true, we're setting it to true, which does nothing, because it was already true. It's as pointless as x = x;

And if success is false, then we don't go into the body anyway, so we don't do anything.
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Yes ofcourse.

Like if success is false then access is true that was doing the above code that was effecting the whole case

Anyways, Thanks for giving me your precious time


Best regards
 
Consider Paul's rocket mass heater.
 
subject: java.io.FileNotFoundException