Java JTree Path makeLocalFilePath(TreePath treePath)

Here you can find the source of makeLocalFilePath(TreePath treePath)

Description

make Local File Path

License

BSD License

Declaration

public static String makeLocalFilePath(TreePath treePath) 

Method Source Code

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

import javax.swing.tree.TreePath;

public class Main {
    public static String makeLocalFilePath(TreePath treePath) {

        String filePath = "";

        for (Object node : treePath.getPath()) {
            if (node.toString().equals("/"))
                continue;
            filePath += System.getProperty("file.separator") + node.toString();
        }//from   w w w  .  java  2 s. co  m

        return filePath;
    }

    public static String makeLocalFilePath(TreePath treePath, Object drive) {

        String filePath = "";
        String truncDrive = "";

        for (Object node : treePath.getPath()) {
            if (node.toString().equals("/"))
                continue;
            filePath += System.getProperty("file.separator") + node.toString();
        }

        if (drive != null) {
            truncDrive = drive.toString().substring(0, drive.toString().length() - 1);
            return truncDrive + filePath;
        } else {
            return filePath;
        }
    }
}

Related

  1. isFile(TreePath path)
  2. isSource(TreePath path)
  3. isTreePathContainedInExpansionState(TreePath treePath, ArrayList expansionStateStrings)
  4. lastPathComponents(TreePath[] paths)
  5. loadExpansionState(JTree tree, Enumeration expansionState)
  6. makeTreePath(TreeNode treeNode)
  7. pathByAddingChildAsStr(TreePath currPath, String child)
  8. pathContains(TreePath[] paths, Class clazz)
  9. pathToDepth(TreePath path, int depth)