public static String replaceExtension(String filename, String newExtention)
    {
        int i = filename.lastIndexOf('.');

        return (i > 0 && i < filename.length() - 1) ? filename.substring(0,
                i + 1)
                + newExtention : filename;
    }