Java Path Convert To pathToQualifiedName(final String path)

Here you can find the source of pathToQualifiedName(final String path)

Description

Formats a file path to a class into a fully qualified class name.

License

Open Source License

Parameter

Parameter Description
path The relative path to the .class file

Return

The qualified class name.

Declaration

public static String pathToQualifiedName(final String path) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   ww w  .  j a  v a2s. c o  m*/
     * Formats a file path to a class into a fully qualified class name.
     * 
     * @param path
     *            The relative path to the .class file
     * @return The qualified class name.
     */
    public static String pathToQualifiedName(final String path) {
        String delim = System.getProperty("file.separator");
        // if using a windows style separator add the escape character
        if (delim.equals("\\")) {
            delim += "\\";
        }
        String name = path.substring(0, path.lastIndexOf('.'));
        name = name.replaceAll(delim, ".");

        return name;
    }
}

Related

  1. pathToName(String path)
  2. pathToName(String path, String fileName)
  3. pathTooLong()
  4. pathToPackageName(String relativeFileName, boolean leadingDot)
  5. pathToQualifiedClassName(final String path)
  6. pathToResource(final String name)
  7. pathToSelfLink()
  8. pathToString(double[][] p)
  9. pathToURI(String path)