Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

Random file selection

Thread view: 
nospam@invalid.invalid - 01 Dec 2006 07:50 GMT
I'm trying to think of a way to select random unknown files from a known
root folder. The files are randomly in sub-folders and sub-sub folders, etc
which I would like to try to select on a fairly arbitrary basis. Is there
any random recursive way to select files from a root folder in the way I'm
trying?

TIA
Piotr Pejas - 01 Dec 2006 07:59 GMT
Hello,
Simple method to read all files in direcory with subdirectories can be
implemented in this way:

public void readDirectory( String directoryPath ) throws Exception {
    addDirectory( new File( directoryPath ) );
}
private void addDirectory( File file ) throws Exception {
    if( file.isDirectory() ) {
        for( File f : file.listFiles() ) {
            addDirectory( f );
        }
    }
    else {
        addFile( file );
    }
}
You have to implement addFile( File file ); method.

Best Regards
Piotr Pejas

Signature

Piotr Pejas
Java devleloper
Yumasoft sp. z o. o
www.yumasoft.pl
tel. +4871 78 44 123

nospam@invalid.invalid napisal(a):

> I'm trying to think of a way to select random unknown files from a known
> root folder. The files are randomly in sub-folders and sub-sub folders, etc
[quoted text clipped - 3 lines]
>
> TIA
nospam@invalid.invalid - 01 Dec 2006 12:47 GMT
Thanks for the help!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.