Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**
     * Ensures that a filename always ends with the file name extension
     * @param name
     * @return
     */
    public static String getFileNameWithExtension(String name, String fileNameExtension) {
        int len = fileNameExtension.length();
        String substr = name.substring(Math.max(0, name.length() - len));
        if (!substr.equals(fileNameExtension)) {
            name = name + fileNameExtension;
        }
        return name;
    }
}