### Inline Java ListFiles

To list the files from a folder, Inline Java can be used (requires the JavaObject library).
Inline Java Code
#If JAVA
import java.io.File;
//List the files from a folder and return as stringarray
public static String[] ListFiles(String searchpath) {
File f = null;
String[] paths;
try {
f = new File(searchpath);
paths = f.list();
return paths;
} catch(Exception e){
e.printStackTrace();
return null;
}
}
#End If
B4J Code Example
'Declare the JavaObject holding the files
Private joFiles As JavaObject = Me
'Get all files from the dirassets folder by calling the Inline Java Method
Dim f() As String = joFiles.RunMethod("ListFiles", Array(File.DirApp.Replace("Objects", "Files")))
'No files found
If f = Null Then Return
'Files found
For i = 0 To f.Length - 1
Log(f(i))
Next

Changed: , Category: Inline Java, File: T6C201M1477.htm, ID: 1477