Import library to use File datatype

Stupid question I know, but after lots of Googling, I turn to you. So far I have added these libraries,
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;

But every time I try something like, File f = new File(LookIn); (LookIn is a string) I get an error,
[javac] /compiler/android/src/DaAqv/com/aicode/filesandfolders/FilesAndFolders.java:59: error: cannot find symbol
[javac] File f = new File(LookIn);
[javac] ^

Here’s the code if it helps,
@SimpleFunction(description = “Return the list of files in the specified directory”)
public List ListOfFiles(String LookIn){
File f = new File(LookIn);
String files = f.list;
return Arrays.asList(files);
}

Thanks.

Almost forgot, I know this already exists in the MIT AI but I still want to be able to do this anyway.

You are importing files, but in the error its missing File Class.

try importing java.io.File

Strange, but the cut and past of the code left a couple things out (it should have said List). Anyway, I have intermediate skills in Visual Basic, but a complete noob at Java. Besides your help, I also figured out on my own that String files = f.list; doesn’t work but String files = f.list(); does. I swear, sometimes it’s the little things.
Anyway, thanks.

1 Like