File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes FileNotFoundException in wired situation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "FileNotFoundException in wired situation" Watch "FileNotFoundException in wired situation" New topic
Author

FileNotFoundException in wired situation

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

i had build an application in java which runs properly in win7 but throws n FileNotFoundException in winxp , can any one explain me why ?


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18966
    
  40

naved momin wrote:i had build an application in java which runs properly in win7 but throws n FileNotFoundException in winxp , can any one explain me why ?


Well, the most likely reason is that the file exists on win 7, but either doesn't exist, or isn't accessible on XP.

Henry


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

Joined: Jul 03, 2011
Posts: 692

Henry Wong wrote:
naved momin wrote:i had build an application in java which runs properly in win7 but throws n FileNotFoundException in winxp , can any one explain me why ?


Well, the most likely reason is that the file exists on win 7, but either doesn't exist, or isn't accessible on XP.

Henry

thanks for reply henry but there is a strong reason behind asking this question
I am chosing the file using JFileChooser so there is no option that the file i have choice doesn't reside on the pc.
now what you have to say ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18879
    
    8

I'm going to say there is a bug in your code.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39773
    
  28
naved momin wrote: . . . now what you have to say ?
Careful. Some people might think such talk rude.

The file not found Exception (FNF) can be thrown in several circumstances, as you can find from its documentation. There is an example on that link of when a file may exist, but you still suffer an FNF. It is possible that you are actually trying to open a file which as a system file is inaccessible to you.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

Paul Clapham wrote:I'm going to say there is a bug in your code.

OK if I agree than, my question is why it works on win7 ? it should also not work in win7
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

Campbell Ritchie wrote:
naved momin wrote: . . . now what you have to say ?
Careful. Some people might think such talk rude.

The file not found Exception (FNF) can be thrown in several circumstances, as you can find from its documentation. There is an example on that link of when a file may exist, but you still suffer an FNF. It is possible that you are actually trying to open a file which as a system file is inaccessible to you.

OK , I will give another try on some other pc and then lets see what happens next ... will continue
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18879
    
    8

Why should it? There's no guarantee that two Windows computers are going to have exactly the same set of files. In fact it's a certainty that they won't. So it's perfectly possible that you can access file X on Computer A (because it exists there) but not on Computer B (because it doesn't exist there).

So come on. You're claiming that your code doesn't have a bug, but that the Java JRE has a bug which has gone unnoticed by millions of programmers until you found it. That's a waste of time for all concerned. The best bet is that your code has a bug, and you should proceed on that basis.
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

Paul Clapham wrote:Why should it? There's no guarantee that two Windows computers are going to have exactly the same set of files. In fact it's a certainty that they won't. So it's perfectly possible that you can access file X on Computer A (because it exists there) but not on Computer B (because it doesn't exist there).

So come on. You're claiming that your code doesn't have a bug, but that the Java JRE has a bug which has gone unnoticed by millions of programmers until you found it. That's a waste of time for all concerned. The best bet is that your code has a bug, and you should proceed on that basis.

oohh! I m not telling JRE has a bug , I know there are more intelligent people then me including you all, but I need to know whether any one has faced this same problem and if yes he can help me sorting out this one ....
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18879
    
    8

Of course. Everybody has had the situation where they couldn't find a file because they did something wrong. Imagining that nobody else has ever had such a problem is a rather strange way of starting to investigate.

I'm sure you already know about debugging. In this case display the full path of the file which doesn't exist, and look at it.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

The java.io.File class has a number of useful methods that you should call and then print out the results, so you can learn about the file in question. For instance, getFullPath() (or something like that), exists(), isFile(), icanRead(), etc.

Look at File's methods and think about all the things you might want to learn about that file that might help you build a more complete picture of what's going on.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileNotFoundException in wired situation