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

JFileChooser Exception

Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 165

Hi all I'm trying to restore database file to mysql table. I'm using JFileChooser to do this following is my code and its throwing File Not Found Exception. Can somebody help me please.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

Of course. Your first step is to find out which line of code is throwing the exception. You would do that by looking at the stack trace.

If you don't know how to interpret a stack trace, then don't hesitate to ask about that here.
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 165

You would do that by looking at the stack trace


Thanks for your reply Paul, well as you said, it does show the stack trace. But what I have understood is the following--
if you will observe f.getAbsolutePath(); this bit of code, stores the file path which includes \ this sign which is escape character! but when I replaced \ with / while running a program, then it runs properly. So, now I have a question that do I need to replace slashes every time I try to backup? If no then I'd request you to help me out with that. Also, teach me how to work with StackTrace please

Many Thanks!
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 175
    
    1



This will print the error message in the console with the error lines. From this you can find, in which line the error occurred..

I don't think the reason is that \ is an escape character. That's because I have used getAbsolutePath() in my programs too. But I haven't got any errors..!

Ramesh-X
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

On the other hand I think it's quite likely the reason is that \ is an escape character. But it would help considerably if you posted the actual code which throws the exception and not just some code which is sort of like that code. So how about if you do that?
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 175
    
    1



This is the code I used and I didn't get any error..

Through \ is an escape character, here the variable store \\ . You can see when debugging..
But when you use System.out.println(path) it prints only \ as \\ refers "\". But don't think that the variable store only \...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

Ramesh Pramuditha Rathnayake wrote:This is the code I used and I didn't get any error..


Ah, so your problem is actually solved. I didn't quite understand that from your earlier posts. Excellent!
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 175
    
    1

I said that, if we write System.out.println(path) the path name will print as C:\myFolder\backUp.sql..
But actually path name is stored in the variable as C:\\myFolder\\backUp.sql.. We can see it when debugging the program.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFileChooser Exception