Results 1 to 5 of 5
- 05-02-2012, 04:18 PM #1
Member
- Join Date
- May 2012
- Posts
- 2
- Rep Power
- 0
Get directory files list as a stream
Hi
Probably at first glance the question seems very simple but it's no so.
The system I'm writing kinda content analytic tool which knows to work with File System as
one of possible content source repository.We need to run through provided File System root folder and process all files under the root.The system is required to be very responsive, the problems starts when the root folder is located on the remote machine and the number of files under each folder is extremely big (talking about millions of files under single folder)
The way I use to get all available files from folder is very straightforward
File.listFiles()
I'm afraid it's the only way java api provides to obtain the list of all files (names/file objects)
As you know the method returns list of file when it completed to read all of them.
My goal is to find a way to get this list kinda steam
Any thoughts, suggestions will be appreciated
- 05-03-2012, 07:13 PM #2
Member
- Join Date
- Mar 2012
- Location
- Novosibirsk, Russia
- Posts
- 13
- Rep Power
- 0
Re: Get directory files list as a stream
I did not check that, but probably File.listFiles(FileFilter filter) can help. Run it in in a separate thread. Make FileFilter.accept(File path) to write path into a blocking queue and return false. In another thread, read paths from the queue.
- 05-03-2012, 07:46 PM #3
Member
- Join Date
- Mar 2012
- Location
- Novosibirsk, Russia
- Posts
- 13
- Rep Power
- 0
Re: Get directory files list as a stream
File.listFiles() won't work as it calls File.list() internally.
But java 7 has new class Files with methods newDirectoryStream() and walkFileTree().
- 05-04-2012, 09:42 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Get directory files list as a stream
Further proof that I really need to start doing more stuff in Java 7.
Please do not ask for code as refusal often offends.
- 05-04-2012, 12:26 PM #5
Member
- Join Date
- May 2012
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
How to get the list of Files inthe Directory and write data into them One by One
By deshmukh.niraj04 in forum New To JavaReplies: 4Last Post: 06-01-2011, 03:28 PM -
Create a table with buttons and the files list of a directory.
By danielpereira in forum Advanced JavaReplies: 1Last Post: 11-22-2010, 06:43 PM -
Populating a gui list box with the files in a directory
By josejvelezcolon in forum New To JavaReplies: 1Last Post: 08-10-2009, 04:50 PM -
how to list certain files in a given directory in java
By corpusluteum in forum New To JavaReplies: 6Last Post: 09-24-2008, 12:19 AM -
How can I get list of files in a directory
By karma in forum New To JavaReplies: 2Last Post: 12-14-2007, 11:20 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks