Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static final String pattern = "(\\.[a-zA-Z0-9]{2,6}$)";

    /**
     * form file extention to lower case
     * 
     * @param fileName
     * @return
     */
    public static String lowerExtension(String fileName) {

        Pattern p = Pattern.compile(pattern);
        Matcher m = p.matcher(fileName);
        if (m.find()) {
            String extName = m.group().toLowerCase();
            fileName = fileName.replaceAll("(.[a-zA-Z0-9]+)$", extName);
        }

        return fileName;
    }
}