I am trying to get name of a File
object without its extension, e.g. getting "vegetation" when the filename is "vegetation.txt." I have tried implementing this code:
openFile = fileChooser.getSelectedFile();
String[] tokens = openFile.getName().split(".");
String name = tokens[0];
Unfortunately, it returns a null
object. There is a problem just in the defining the String
object, I guess, because the method getName()
works correctly; it gives me the name of the file with its extension.
Do you have any idea?