Java Class Simple Name Get simpleClassName(Class clazz)

Here you can find the source of simpleClassName(Class clazz)

Description

simple Class Name

License

Open Source License

Declaration

public static String simpleClassName(Class<?> clazz) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009 Neil Bartlett.// www  .j a v  a  2s . c  om
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Neil Bartlett - initial API and implementation
 ******************************************************************************/

public class Main {
    public static String simpleClassName(Class<?> clazz) {
        Package pkg = clazz.getPackage();
        String result;
        if (pkg == null)
            result = clazz.getName();
        else
            result = clazz.getName().substring(pkg.getName().length() + 1);
        return result;
    }
}

Related

  1. simpleClassName(Class cl)
  2. simpleClassName(Class klass)
  3. simpleClassName(Class clazz)
  4. simpleClassName(Class clazz)
  5. simpleClassName(Class type)
  6. simpleClassName(final String className)