Java File Name to Class Name fileNameToClassName(String f)

Here you can find the source of fileNameToClassName(String f)

Description

file Name To Class Name

License

Open Source License

Declaration

public static String fileNameToClassName(String f) 

Method Source Code

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

public class Main {
    public static String fileNameToClassName(String f) {
        f = removeFromEnd(f, ".class");
        f = removeFromEnd(f, ".java");
        return f.replace('\\', '.').replace('/', '.');
    }/*from   w ww  . jav a2 s  .  c o m*/

    private static String removeFromEnd(String s, String f) {
        return s.endsWith(f) ? s.substring(0, s.length() - f.length()) : s;
    }
}

Related

  1. fileNameToClass(String fileName)
  2. filenameToClassname(String filename)
  3. filenameToClassname(String fileName)