Java - Write code to strip Extension from a file name in String

Requirements

Write code to strip Extension from a file name in String

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String s = "book2s.com";
        System.out.println(stripExtension(s));
    }/*from  ww w  .  j  a v a  2s.c om*/

    public static String stripExtension(String s) {
        if (s.contains(".") == false) {
            return s;
        }
        try {
            return s.substring(0, s.lastIndexOf("."));
        } catch (StringIndexOutOfBoundsException e) {
            e.printStackTrace();
            //System.out.print(s);
        }
        return s;

    }
}