This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
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

Finding files

 
Martin Vietor
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

as usual I am sure you will be able to help my unsolvable problem in one line

I would likt to load some csv-file data. There are several files, I would like the user to be able to choose one. Is there a way to read which files are in a folder without knowing the names? Basically like any Windows application. Click "Open", get a list of files, choose one, it gets loaded.

Thanks, M
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out which methods java.io.File has for listing (hint, hint) the contents of a folder.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what java.awt.FileDialog and javax.swing.JFileChooser do. If you want to roll your own, then new File("dir").listFiles() would come in handy.
 
Martin Vietor
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a bunch, both are exactly the answers I was looking for
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic