Iterate over a files in a directory
Copy this code and paste it in your HTML
package com.asset.jupiter.testing.testEJB;
import java.io.File;
/**
* @Author:Khaled Talaat
*/
public class FilesReader {
public FilesReader() {
}
public static void main
(String[] args
){ FilesReader filesReader = new FilesReader();
String path
= "D:\\Jupiter\\Documentation\\Core\\samples"; filesReader.
searchFolders(new File(path
)); }
public void searchFolders
(File file
) { if(file.isDirectory()){
String internalNames
[] = file.
list(); for(int i=0; i<internalNames.length; i++){
searchFolders
(new File(file.
getAbsolutePath() + "\\" + internalNames
[i
])); }
} else {
String[] splitted
= file.
getName().
split(".java"); System.
out.
println(splitted
[0]); }
}
}
Report this snippet
Comments
Subscribe to comments