Java Utililty Methods Path Convert To

List of utility methods to do Path Convert To

Description

The list of methods to do Path Convert To are organized into topic(s).

Method

StringpathToEmbedded(String relationType)
path To Embedded
return String.format("_embedded['%s']", relationType);
String[]pathToFields(String beanPath)
path To Fields
return beanPath.split(BEAN_PATH_DELIM_REGEX);
StringpathToFile(String f)
given a filename, strip off the directory prefix (if any) and return it.
String separator = System.getProperty("file.separator");
int endOfPath = f.lastIndexOf(separator);
if (endOfPath == -1) {
    return "." + separator;
} else {
    return f.substring(0, endOfPath + 1);
StringpathToFullyQualifiedName(String classpath, String path)
path To Fully Qualified Name
char[] buff = new char[path.length()];
String fqname = null;
for (int i = 0; i < buff.length; i++) {
    if (path.charAt(i) == '/' || path.charAt(i) == '\\') {
        buff[i] = '.';
    } else {
        buff[i] = path.charAt(i);
int classpathLength = 0;
if (classpath != null) {
    classpathLength = classpath.length() + 1;
int classNameLength = path.length() - classpathLength - new String(".class").length();
fqname = new String(buff, classpathLength, classNameLength);
return fqname;
StringpathToName(String path)
path To Name
return path.replace('/', '.').replace('\\', '.');
StringpathToName(String path, String fileName)
Replaces forward slashes in path with periods and returns a file name based on the path information
return path.split("m/s/")[1].replace("/", ".") + fileName;
IllegalArgumentExceptionpathTooLong()
path Too Long
return new IllegalArgumentException(
        "The specified path, file name, or both are too long. The fully qualified"
                + " file name must be less than 260 characters, and the directory name must"
                + " be less than 248 characters.");
StringpathToPackageName(String relativeFileName, boolean leadingDot)
path To Package Name
return (!leadingDot && relativeFileName.startsWith("/") ? relativeFileName.substring(1) : relativeFileName)
        .replaceAll("/", ".");
StringpathToQualifiedClassName(final String path)
Return a fully qualified class name of a path.
return path.replaceAll("/", ".").substring(0, path.length() - CLASS_SUFFIX.length());
StringpathToQualifiedName(final String path)
Formats a file path to a class into a fully qualified class name.
String delim = System.getProperty("file.separator");
if (delim.equals("\\")) {
    delim += "\\";
String name = path.substring(0, path.lastIndexOf('.'));
name = name.replaceAll(delim, ".");
return name;