If you, like me, would preferably use some library code where they have thought of all special cases, such as what appears if you pass in null or dots in the path but not in the filename, you can practice the following:
import org.apache.commons.io.FilenameUtils;
String fileNameWithOutExt = FilenameUtils.removeExtension(fileNameWithExt);