File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Finding files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Finding files" Watch "Finding files" New topic

Finding files

Martin Vietor
Ranch Hand

Joined: Oct 31, 2008
Posts: 40
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

The problem people have in trying to create something foolproof is that they generally underestimate the inginuity of fools.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20279

Check out which methods has for listing (hint, hint) the contents of a folder.

How To Ask Questions How To Answer Questions
Lester Burnham

Joined: Oct 14, 2008
Posts: 1337
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

Joined: Oct 31, 2008
Posts: 40
Thanks a bunch, both are exactly the answers I was looking for
I agree. Here's the link:
subject: Finding files
It's not a secret anymore!