You don’t need split() for parsing paths! Just use methods from Java’s File class:
Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html
Along w/ some methods from class String:
Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html
final File f = sketchFile("img.bmp");
println(f);
final String folderpath = f.getParent();
println(folderpath);
final String file = f.getName();
println(file);
final int idx = file.indexOf('.');
final String filename = file.substring(0, idx);
println(filename);
final String ext = file.substring(idx);
println(ext);
exit();