[Advanced-java] File System

Joe Sam Shirah jshirah at attglobal.net
Fri Jun 27 07:56:28 2003


    HI Jukka,

    As it happens, I'm in the middle of testing a series that gets zip files
in a directory, reads an xml file inside the zip file, determines from this
a server name, and finally FTPs the zip file to the server.

    Here's a two line ( untested ) mod of the code I'm using to get the
files in the directory:

File fDir = new File( "MyDirName" );
File[] afTheFiles = fDir.listFiles();

    The first line creates a File ( which is really a directory ), from a
String, which is the name of the directory.

    The second line gets a list of Files in the directory into an array.

    The only other thing of interest is that the names can be either files
or subdirectories, so use either File.isDirectory() or File.isFile() to be
sure what you have.


                                                         Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO         -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?             http://www.jguru.com/faq/Java400



----- Original Message -----
From: "Jukka Sundberg" <jukka@citrus.fi>
To: <advanced-java@lists.xcf.berkeley.edu>
Sent: Friday, June 27, 2003 1:07 AM
Subject: [Advanced-java] File System


> Does anyone know how to read file names in specified directory?
>