Infolinks In Text Ads

Jun 24, 2010

How to read system directory and files in java code examples

import java.io.File;

public class TestDirReader{

  public static void main(String[] args) {

              File folder = new File("C://testDir");

            File[] filesList= folder.listFiles();


            for (int i = 0; i < filesList.length; i++) {
              if (filesList[i].isDirectory()) {
                System.out.println("Directory Name :" + filesList[i].getName());
              }else if (filesList[i].isFile()) {
                System.out.println("File Name :" + filesList[i].getName());
              }

            }

  }

}

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...