Java tutorial
//package com.java2s; /* * Copyright (c) 2011 HawkinsSoftware * 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: * Byron Hawkins of HawkinsSoftware */ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final Pattern PLAIN_NAME_START_PATTERN = Pattern.compile("\\.[A-Z]"); public static String getPlainName(Class<?> type) { String typeName = type.getCanonicalName(); if (typeName == null) { typeName = type.getName().replace('$', '.'); } return getPlainName(typeName); } public static String getPlainName(String qualifiedName) { Matcher matcher = PLAIN_NAME_START_PATTERN.matcher(qualifiedName); if (matcher.find()) { return qualifiedName.substring(matcher.start() + 1, qualifiedName.length()); } else { return qualifiedName; } } }