Try this:
***********************************************************
import java.io.*;

public class GetFiles {
        public static void main(String []args) {
                File file = new File("."); //for current folder
                                           //or type the desired folder
                File files[] = file.listFiles();

                //or String files[] = files.list();

                for (int i = 0; i < files.length;i++) {
                        System.out.println(files[i]);
                }
        }
}
***********************************************************
I think this is what you need.

Panos







>From: Greg Nudelman <[EMAIL PROTECTED]>
>Reply-To: "JDJList" <[EMAIL PROTECTED]>
>To: "JDJList" <[EMAIL PROTECTED]>
>Subject: [jdjlist] RE: get the names of all the file under a folder
>Date: Fri, 10 May 2002 11:21:05 -0700
>
>Try Perl...
>
>This example processes all the files in the directory:
>
>$dirname =  shift @ARGV;
>
>opendir(DIR, $dirname) or die "can not open $dirname : $!\n";
>
>while( defined ($filename = readdir DIR) ) {
>#$filename = shift @ARGV;
>
>     print "$dirname/$filename\n";
>
>     if($filename ne "." && $filename ne "..") {
>         open(INPUTFILE, "< $dirname/$filename") or die "can not open
>$dirname/$filename : $!\n";
>         while(<INPUTFILE>) {
>               #DO SOMETHING WITH THE FILE'S CONTENTS....
>
>         }
>     }
>
>}
>
>
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>Sent: Friday, May 10, 2002 9:39 AM
>To: JDJList
>Subject: [jdjlist] get the names of all the file under a folder
>
>
>Hi all,
>
>Does anybody know how to get the names of all the files under a folder?  I
>assume we should be able to create an Iterator of the names using some
>Class.
>
>Any experience about it?
>
>
>Thanks and have a great weekend!
>
>TongHua
>
>
>
>____________________________________________________________________________
>______________________________________________________
>
>
>This e-mail is intended for the use of the addressee(s) only and may
>contain privileged, confidential, or proprietary information that is exempt
>from disclosure under law.  If you have received this message in error,
>please inform us promptly by reply e-mail, then delete the e-mail and
>destroy any printed copy.   Thank you.
>
>
>To change your membership options, refer to:
>http://www.sys-con.com/java/list.cfm
>
>To change your membership options, refer to:
>http://www.sys-con.com/java/list.cfm


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to