Here you can find the source of extractFileWithoutExtension(String filename)
public static String extractFileWithoutExtension(String filename)
//package com.java2s; public class Main { public static String extractFileWithoutExtension(String filename) { try {//from ww w . j a v a2 s . co m int cutlen = extractFileExtension(filename).length(); if (cutlen == 0) return filename; return filename.substring(0, filename.length() - cutlen - 1); } catch (Exception e) { return filename; } } public static String extractFileExtension(String filename) { int lastslash = filename.lastIndexOf("/"); if (lastslash != -1) filename = filename.substring(lastslash + 1); lastslash = filename.lastIndexOf("\\"); if (lastslash != -1) filename = filename.substring(lastslash + 1); int lastdot = filename.lastIndexOf("."); if (lastdot != -1) return filename.substring(lastdot + 1); else return ""; } }