String fname = file.getName(); int pos = fname.lastIndexOf("."); if (pos > 0) { fname = fname.substring(0, pos); }