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));
    }//from ww  w .j  a v  a 2  s  .  c o m

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