File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Finding files" Watch "Finding files" New topic
Author

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
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Lester Burnham
Rancher

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: http://aspose.com/file-tools
 
subject: Finding files