package JavaWorld;
import java.io.File;
public class ListFileInFolder {
public static void main(String[] args) {
File myFolder = new File("C:/Users/Vishnuyardini/Desktop");
File afile[];
int j = (afile = myFolder.listFiles()).length;
for(int i = 0; i < j; i++)
{
File fileEntry = afile[i];
String fileName = fileEntry.getName();
System.out.println(fileName);
}
}
}
output:
import java.io.File;
public class ListFileInFolder {
public static void main(String[] args) {
File myFolder = new File("C:/Users/Vishnuyardini/Desktop");
File afile[];
int j = (afile = myFolder.listFiles()).length;
for(int i = 0; i < j; i++)
{
File fileEntry = afile[i];
String fileName = fileEntry.getName();
System.out.println(fileName);
}
}
}
output:
No comments:
Post a Comment