package fileCountAndName;
import java.io.File;
import java.io.IOException;
public class fileCountAndName {
public static void main(String[] argv) throws IOException {
File folder = new File("C:\\Users\\Desktop\\Files\\");
File[] listOfFiles = folder.listFiles(); int count=0;
System.out.println("File Inside the folder are");
for (int i = 0; i < listOfFiles.length; i++)
{
if (listOfFiles[i].isFile())
{
count++;
File f = new File("C:\\Users\\Desktop\\Files\\"+listOfFiles[i].getName()); System.out.println(f.getName());
}
}
System.out.println("Total number of files are :"+count);
}
}
No comments:
Post a Comment