Java Utililty Methods Path Create

List of utility methods to do Path Create

Description

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

Method

StringmakePathAbsolute(String path)
make Path Absolute
if (!pathIsRelative(path)) {
    return path;
return path;
StringmakePathASafeFileName(String filePath)
Used by various tests to make sure the path is safe for Windows
return new File(filePath).getPath().replaceAll("\\\\", "/");
StringmakePathFile(String javaConnectorSourcePath, String packageName, String className)
Make path file.
String p = packageName.replace(".", File.separator);
return javaConnectorSourcePath + File.separator + p + File.separator + className + ".java";
StringmakePathFromDate()
Make a string that defines a path from the root of the storage service's documents tree to a specific document directory.
Calendar now = Calendar.getInstance();
return intToString(now.get(Calendar.YEAR), 4) + File.separator + intToString(now.get(Calendar.MONTH) + 1, 2)
        + File.separator + intToString(now.get(Calendar.DAY_OF_MONTH), 2)
        + intToString(now.get(Calendar.HOUR_OF_DAY), 2) + intToString(now.get(Calendar.MINUTE), 2)
        + intToString(now.get(Calendar.SECOND), 2) + intToString(now.get(Calendar.MILLISECOND), 3);
StringmakePathFromStrings(List files)
make Path From Strings
StringBuilder result = new StringBuilder();
for (String file : files) {
    if (result.length() != 0) {
        result.append(File.pathSeparator);
    result.append(file);
return result.toString();
...
StringmakePathName(String directoryName, String fileName)
make Path Name
String pathName;
if (directoryName != null && !directoryName.isEmpty()) {
    pathName = directoryName + File.separator + fileName;
} else {
    pathName = fileName;
return pathName;
StringmakePathRelativeTo(String path, final File basedir)
make Path Relative To
if (basedir == null) {
    return path;
if (path == null) {
    return null;
path = path.trim();
String base = basedir.getAbsolutePath();
...
voidmakePaths(File path)
Create a directory at the path given (if there isn't already one there)
if (!path.getParentFile().exists())
    makePaths(path.getParentFile());
if (!path.exists())
    path.mkdir();
StringtoPath(Class klazz)
to Path
return toPath(klazz.getName()) + CLASS_EXTENSION;
StringtoPath(Object[] path)
to Path
String returned = "";
for (Object obj : path) {
    returned += obj + ".";
return returned.substring(0, returned.length());