Java Class File Name Get classFileName(String packageName, String className)

Here you can find the source of classFileName(String packageName, String className)

Description

class File Name

License

Open Source License

Parameter

Parameter Description
packageName a parameter
className a parameter

Declaration

public static String classFileName(String packageName, String className) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  ww  .j a v  a2s.co m*/
     * 
     * @param packageName
     * @param className
     * @return
     */
    public static String classFileName(String packageName, String className) {
        return getPackagedFileName(packageName, className, "java");
    }

    /**
     * @param packageName
     *            name of the package to resolve
     * @param fileName
     *            name of the file to append
     * @param fileExtension
     *            extension of the file to append
     * @return the complete file path consisting of the
     *         packageName+fileName+fileExtension
     */
    public static String getPackagedFileName(String packageName, String fileName, String fileExtension) {

        StringBuffer filePath = new StringBuffer(70);
        if (packageName != null && packageName.length() > 0) {
            filePath.append(packageName.replace(".", "/"));
            filePath.append("/");
        }
        filePath.append(fileName);
        filePath.append(".");
        filePath.append(fileExtension);
        return filePath.toString();
    }
}

Related

  1. classFileName(Class clazz)
  2. classFileName(Class cl)
  3. classFileName(String className)
  4. classFileNameFromClassName(String classname)
  5. classFileNameWithTypeAndExt(String className, String type, String ext)