Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java find file path

 
Rus Corina
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am trying to make a program which creates a JTable with some info in it and then exports the table to Excel. I already found the code which does that, but I was wondering if there is a way to give the user a possibility to choose the path where he wants to save the Excel file. Like for example when you download a file from the internet and a small window appears which gives a tree-like structure of the files and folders on the computers.
 
Paul Clapham
Sheriff
Pie
Posts: 20764
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JFileChooser?
 
Rus Corina
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, for what I've read, I think JFileChooser is what I want. I just didn't know exactly what to search for (keyword) . It can save files as well right?
 
Paul Clapham
Sheriff
Pie
Posts: 20764
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it's a file chooser. It doesn't do any file saving, it just lets the user choose a file (or more precisely, the name of a file). But you already have the file-saving code written, right?
 
Rus Corina
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have it, but I needed the file chooser to let me get the path where I want my file to be saved (the folder path). But I can't seem to be able to do that, to get the path. Once I have the pth, I only need to add to it the filename, which will always be the same.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the API for JFileChooser and follow the link to the tutorial on How to Use File Choosers. It's all there, including a fair abount of sample code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic