Java tutorial
//package com.java2s; public class Main { public static String removeExtension(final String path) { final int dot = path.lastIndexOf("."); if (-1 == dot || 0 == dot || dot <= path.lastIndexOf("/") + 1) { return path; } else { return path.substring(0, dot); } } }