I want to create an Image slide from gallery (filePath). I want my code auto search all image in this filePath and put it in an ArrayList. But I don't know how?
Asked
Active
Viewed 48 times
0
-
1http://stackoverflow.com/questions/2056221/recursively-list-files-in-java – Balázs Édes Dec 01 '14 at 06:08
1 Answers
5
This code will help you to put all the images from your computer folder. And you can also use this code in your JSP page by which you can easily show your all images on Browser.
File folder = new File("X:/images/"); File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
System.out.println("File " + listOfFiles[i].getName());
} else if (listOfFiles[i].isDirectory()) {
System.out.println("Directory " + listOfFiles[i].getName());
}
}

Anup
- 316
- 1
- 3
- 13