Java - Write code to strip Extension

Requirements

Write code to strip Extension

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String filename = "book2s.com";
        System.out.println(stripExtension(filename));
    }/* w w w . j a  v a2  s.  co m*/

    public static String stripExtension(String filename) {
        int index = filename.lastIndexOf(".");
        return (filename.substring(0, index));
    }
}