Saturday, 28 July 2012

DirList example in java program using file handling


import java.io.*;
class DirList {
      public static void main(String args[]) {
      String dirname="/subha";
      File f1=new File(dirname);
        if(f1.isDirectory()) {
            System.out.println("Directory of " + dirname);
            String s[]=f1.list();
            for(int i=0;i<s.length;i++)
            {
                    File f=new File(dirname + "/" +s[i]);
                    if(f.isDirectory()) {
                            System.out.println(s[i] + " is a Directory");
                    }
            else
             {
                            System.out.println(s[i] + " is a File");
              }
                    }
       }
      else
            {
                         System.out.println(dirname + " is not a directory");
             }
       }
}

2 comments:

  1. Pega Developer Course
    The Pega Developer Course trains you in end-to-end application building, from case lifecycle management to advanced integrations. Ideal for those seeking Pega Developer or Architect roles.

    ReplyDelete
  2. Great article! Very helpful for readers looking for clear insights. For those interested in skill development, check out best training institute in Chennai offering quality courses. Helpful information about best guest posting sites.

    ReplyDelete