Calling a varargs method is not a problem
(Me).as(JavaObject).RunMethod("test", Array("Fred", Array As String("one", "two", "three")))
...
#If Java
public static void test(String name, String ... s){
for (String ss : s){
System.out.println(ss);
}
}
#End If
Will work quite happily.
It works because we can have an array of String.
Your problem will be you are passing a File object, which B4X knows nothing about.
You can either pass them as an Object Array, then in the java code cast them back to File , or pass the filenames as Strings and create the File in the java code.
The first option will require you to create some java objects for the File class.
Dim file1 As JavaObject
file1.InitializeNewInstance("java.io.File",array( "somefilepath" ))
...
(Me).As(JavaObject).RunMethod("process",Array As Object("sometext",Array (file1, file2)))
...
#if java
import java.util.Arrays;
import java.io.File;
public static void process(String name, Object... files) {
File[] f = Arrays.copyOf(files, files.length, File[].class;
for (File file : f){
sub_process(name, file, ".");
}
}
#end if
The second option is easier as using your code you could have
(Me).As(JavaObject).RunMethod("process",Array As Object("sometext",Array As String ("C:/file1.txt", "C:/file2.txt")))
...
#if java
import java.io.File;
public static void process(String name, String... files) {
for (String file : files){
sub_process(name, New File(file), ".");
}
}
#end if
(I hope that is clear enough)