• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JFileChooser Exception

 
Ranch Hand
Posts: 172
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 172
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
Ranch Hand
Posts: 178
2
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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..!
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 178
2
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 178
2
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic