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 Read all text files in a directory? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Read all text files in a directory?" Watch "Read all text files in a directory?" New topic
Author

Read all text files in a directory?

Gary kwlai
Greenhorn

Joined: Dec 24, 2008
Posts: 12
Is there a package in java can read a directory's files one by one ?

Or it doesnt matter it will read a directory if the file path is only a directory? e.g. with scanner class instead of a specific file, can I just give it a directory path so it will read whatever text in that?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Have you checked out java.io.File? It has some methods for listing its children - which include both files and sub folders.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Gary kwlai
Greenhorn

Joined: Dec 24, 2008
Posts: 12
Rob Prime wrote:Have you checked out java.io.File? It has some methods for listing its children - which include both files and sub folders.


thanks for the quick reply, seems like i need to combie the java.io.file with scanner to do what i was intended to , thanks
 
I agree. Here's the link: http://jrebel.com/download
 
subject: Read all text files in a directory?
 
Similar Threads
Listing all in a root (39 Line working code)
javascript src path
Making a GoogleBot like application...
error in reading from a file
Setting Base directory