Java Path Relative nio getFileRelativeFolders(Path basePath, Path filePath)

Here you can find the source of getFileRelativeFolders(Path basePath, Path filePath)

Description

get File Relative Folders

License

LGPL

Declaration

public static List<String> getFileRelativeFolders(Path basePath, Path filePath) 

Method Source Code

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

import java.nio.file.Path;

import java.util.ArrayList;

import java.util.Iterator;
import java.util.List;

public class Main {
    public static List<String> getFileRelativeFolders(Path basePath, Path filePath) {
        List<String> res = new ArrayList<>();
        Path relativize = basePath.relativize(filePath).getParent();
        if (relativize != null) {
            Iterator<Path> iterator = relativize.iterator();
            while (iterator.hasNext()) {
                res.add(iterator.next().toString());
            }//from   w w w .  j  av  a2s.  c o  m
        }
        return res;
    }
}

Related

  1. checkNormalizedRelative(String path)
  2. combinePaths(String baseDir, String relativePath)
  3. get(File basePath, String... relatives)
  4. getChildEntryRelativePath(Path base, Path child, boolean convertToLinuxPath)
  5. getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative)
  6. getOptionalPathRelativeToMavenProjectRoot(File absoluteFile)
  7. getRelativeFilePathToCwd(File file)
  8. getRelativePath(File baseFile, File file, String resultIfImpossible)
  9. getRelativePath(File basePath, File path)