Java Class Name Clean classNameFromQualifiedClassName(String qualifiedName)

Here you can find the source of classNameFromQualifiedClassName(String qualifiedName)

Description

Return only class name of a full qualified (package+classname) string.

License

Open Source License

Parameter

Parameter Description
qualifiedName a parameter

Declaration

public static String classNameFromQualifiedClassName(String qualifiedName) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   w w w .j a v  a 2 s. c  o m*/
     * Return only class name of a full qualified (package+classname) string.
     *
     * @param qualifiedName
     * @return
     */
    public static String classNameFromQualifiedClassName(String qualifiedName) {
        if (qualifiedName == null) {
            throw new IllegalArgumentException("qualifiedName can't be null!");
        }

        int dot_index = qualifiedName.lastIndexOf('.');

        if (dot_index != -1)
            return qualifiedName.substring(dot_index + 1);
        else
            return qualifiedName;
    }
}

Related

  1. classNameFromQualifiedName(String qualifiedCalssName)
  2. classNameOnly(Object o)
  3. classNameWithoutGeneric(String s)
  4. classNameWithoutPackage(Class objectClass)