Java Class Name Convert To classNameToPath(final String className)

Here you can find the source of classNameToPath(final String className)

Description

Convert a class name into a path

License

Open Source License

Parameter

Parameter Description
className the class name

Return

the path

Declaration

public static final String classNameToPath(final String className) 

Method Source Code

//package com.java2s;
/*//from   ww w.  j  a  v a  2s  .c  om
 * JBoss, Home of Professional Open Source.
 * Copyright 2007, Red Hat Middleware LLC, and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

public class Main {
    /**
     * Convert a class name into a path
     * 
     * @param className the class name
     * @return the path
     */
    public static final String classNameToPath(final String className) {
        if (className == null)
            throw new IllegalArgumentException("Null className");

        return className.replace('.', '/') + ".class";
    }

    /**
     * Convert a class into a path
     *
     * @param clazz the class
     * @return the path
     */
    public static final String classNameToPath(final Class<?> clazz) {
        if (clazz == null)
            throw new IllegalArgumentException("Null class");

        return classNameToPath(clazz.getName());
    }
}

Related

  1. classNameToFullyQualifiedClassName(String packageName, String className)
  2. classNameToInternalClassName(String className)
  3. classNameToJavaPath(String name)
  4. classNameToJavaUri(String className)
  5. classNameToPackageName(String fqn)
  6. classNameToPath(String className)
  7. classNameToResource(String className)
  8. classNameToResource(String className)
  9. classNameToResourceKey(String name)