you are pro. thanks
----- Original Message -----
From: Jeetendra
Sent: Monday, September 03, 2001 8:42 PM
Subject: Re: does anyone how to list all files in the specific directory ?

Here is a program that I used to printing names of all the files in a directory.
 
 
 
import java.io.*;
public class DirectoryParser
{
   public static void main(String args[])
   {
      if(args.length <= 0)
      {
         System.out.println("Usage java DirectoryParser <name of the directory>");
   System.exit(1);
      }
 
      File fd0 = new File(args[0]);
      if(!fd0.exists())
      {
   System.out.println("Directory does not exist");
   System.exit(2);
      }
 
      if(fd0.isDirectory() == false)
      {
   System.out.println("The specified path is not a directory");
   System.exit(3);
      }
 
      System.out.println("Directory Exists");
        
      // Parse that directory
      parseDirectory(args[0]);         
   } 
 
   public static void parseDirectory(String strFileName)
   {
 File fd = new File(strFileName);
 String strFileNameList[] = fd.list(); 
 for(int i=0;i<strFileNameList.length;i++)
 {
    File fCurrent = new File(strFileName+"/"+strFileNameList[i]);
    if(fCurrent.isDirectory() == true)
    {
   System.out.println("Directory"+strFileNameList[i]);
   parseDirectory(fCurrent.getAbsolutePath());
      }    
    else
    {
   System.out.println("File Name "+strFileNameList[i]+ "    Directory Name "+fd.getName());
      }
 }
   }
}
 

Jeetendra Dassani
Lead Systems Engineer
Tata Infotech Limited
SEEPZ, Andheri (E)
Mumbai.
Email : [EMAIL PROTECTED]
        [EMAIL PROTECTED]
Telephone: 8291261 X 2775/2465

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of chenghong
Sent: Thursday, July 05, 2001 7:43 AM
To: [EMAIL PROTECTED]
Subject: does anyone how to list all files in the specific directory ?

does anyone how to capture all filename in a directory ??
 
thanks
cheng hong.

Reply via email to