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());
              }

            }

  }

}

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

How to capture finger prints in java

Shallow Copy Deep Copy Java example