Write code to strip Extension from a file name in String
//package com.book2s; public class Main { public static void main(String[] argv) { String s = "book2s.com"; System.out.println(stripExtension(s)); }//www . ja va2s . c o m 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; } }