Java Class Name Get className(String path)

Here you can find the source of className(String path)

Description

class Name

License

Apache License

Declaration

public static String className(String path) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String className(String path) {
        return path.replace('\\', '/').replace('/', '.').substring(0, path.length() - 6);
    }//from w ww  . j  a  v  a  2 s  .  co m

    /**
     * Replace given characters in a given string builder.
     * The number of characters to replace has to match to number of
     * characters serving as a replacement.
     *
     * @param sb string builder containing a string to be modified
     * @param from characters to replaced
     * @param to replacement characters
     * @return original string builder with replaced characters.
     */
    public static StringBuilder replace(StringBuilder sb, CharSequence from, CharSequence to) {
        assert from.length() == to.length();
        for (int i = 0; i < sb.length(); i++)
            for (int j = 0; j < from.length(); j++)
                if (sb.charAt(i) == from.charAt(j))
                    sb.setCharAt(i, to.charAt(j));
        return sb;
    }
}

Related

  1. className(Object value)
  2. className(String classFile, String pre)
  3. className(String classFullName)
  4. className(String fullyQualifiedName)
  5. className(String nodeName)
  6. className(String underScore)
  7. classNames(String description)
  8. classNameSubName(String className)
  9. classNameSubPackage(String className)