Java Class Name Create toClassName(String className)

Here you can find the source of toClassName(String className)

Description

Converts a given string to a valid className (replaces backslashes with .)

License

Open Source License

Parameter

Parameter Description
className to replace backslashes

Return

the valid version of className

Declaration

public static String toClassName(String className) 

Method Source Code

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

public class Main {
    /**/* w w  w . j a va  2s.  c o m*/
     * Converts a given string to a valid className
     * (replaces backslashes with .)
     * 
     * @param className to replace backslashes
     * @return the valid version of className
     */
    public static String toClassName(String className) {
        if (null == className || className.isEmpty()) {
            return className;
        }

        if (className.startsWith(".") || className.startsWith("/")) {
            className = className.substring(1);
        }
        return className.replace("/", ".").replace("\\", ".");
    }
}

Related

  1. toClassName(Class clazz)
  2. toClassName(Enum enumeration)
  3. toClassName(Object obj)
  4. toClassname(String apparatClassname)
  5. toClassName(String className)
  6. toClassName(String className)
  7. toClassName(String fileName)
  8. toClassName(String fileName)
  9. toClassName(String internalName)