List all files in a directory using java
=======List all file with their names in a existing directory on your hard disk=====
String walkImageDir="C://MyDirectory//imageFiles";
File dir = new File(imageDir);
System.out.println("===dir.isDirectory()====="+dir.isDirectory());
if(dir.isDirectory()){
File[] imgFiles = dir.listFiles();
System.out.println("===file dir size:"+imgFiles.length);
for(File image: imgFiles){
System.out.println("====images are :"+image.getName());
}
}
String walkImageDir="C://MyDirectory//imageFiles";
File dir = new File(imageDir);
System.out.println("===dir.isDirectory()====="+dir.isDirectory());
if(dir.isDirectory()){
File[] imgFiles = dir.listFiles();
System.out.println("===file dir size:"+imgFiles.length);
for(File image: imgFiles){
System.out.println("====images are :"+image.getName());
}
}
Comments
Post a Comment