• Post Reply Bookmark Topic Watch Topic
  • New Topic

Read all text files in a directory?  RSS feed

 
Gary kwlai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked out java.io.File? It has some methods for listing its children - which include both files and sub folders.
 
Gary kwlai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!