String fileName = file.getName(); int i = fileName.lastIndexOf('.'); if (i != -1) { fileName = fileName.substring(0, i); }