本文整理汇总了Java中java.nio.file.Path.subpath方法的典型用法代码示例。如果您正苦于以下问题:Java Path.subpath方法的具体用法?Java Path.subpath怎么用?Java Path.subpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.Path
的用法示例。
在下文中一共展示了Path.subpath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyChangedEditedFile
import java.nio.file.Path; //导入方法依赖的package包/类
/**
* Notify about changed the edited file.
*
* @param prevFile the prev file.
* @param newFile the new file.
*/
@FXThread
private void notifyChangedEditedFile(final @NotNull Path prevFile, final @NotNull Path newFile) {
final Path editFile = getEditFile();
if (editFile.equals(prevFile)) {
setEditFile(newFile);
return;
}
if (!editFile.startsWith(prevFile)) return;
final Path relativeFile = editFile.subpath(prevFile.getNameCount(), editFile.getNameCount());
final Path resultFile = newFile.resolve(relativeFile);
setEditFile(resultFile);
}
示例2: mergeDifferences
import java.nio.file.Path; //导入方法依赖的package包/类
private Path mergeDifferences(Path path, Path newPath) {
int start = newPath.relativize(path).getNameCount();
int end = path.getNameCount();
Path subPath = path.subpath(start, end);
return newPath.resolve(subPath);
}
示例3: getBundleSubDir
import java.nio.file.Path; //导入方法依赖的package包/类
private String getBundleSubDir(final Path relChangedDir) {
if (relChangedDir.getNameCount() == 1) {
return StringUtils.EMPTY;
}
final Path subPath = relChangedDir.subpath(1, relChangedDir.getNameCount());
// ensure that we use '/' as the JCR path separator, even if the filesystem path uses something else
return StringUtils.join(subPath.iterator(), '/');
}
示例4: testExtractFromDir
import java.nio.file.Path; //导入方法依赖的package包/类
public void testExtractFromDir() {
Path imagePath = Paths.get(getImagePath());
Path imageDirPath = imagePath.subpath(0, imagePath.getNameCount() - 1);
jimage("extract", imageDirPath.toString())
.assertFailure()
.assertShowsError();
}
示例5: fillChildren
import java.nio.file.Path; //导入方法依赖的package包/类
@FXThread
private void fillChildren(@NotNull final Path prevFile, @NotNull final Path newFile,
@NotNull final Array<TreeItem<ResourceElement>> children) {
for (final TreeItem<ResourceElement> child : children) {
final ResourceElement resourceElement = child.getValue();
final Path file = resourceElement.getFile();
final Path relativeFile = file.subpath(prevFile.getNameCount(), file.getNameCount());
final Path resultFile = newFile.resolve(relativeFile);
child.setValue(createFor(resultFile));
}
}
示例6: createOutputDirectoryTree
import java.nio.file.Path; //导入方法依赖的package包/类
/**
* Creates the directory tree in {@link CleanupSettings#getOutputBaseDirectory()} using the given path. The given
* path will be stripped from the root directory. The parent directories of the target file will be created if the
* tree does not exist.
* <p>
* Example: {@code mediaSource} is "0/subdir/file.ext". The base output dir is assumed to be "output". The return
* value results in being "output/subdir/file.ext", where "output/subdir" will be created. The file itself will NOT
* be created.
* </p>
*
* @param mediaSource the media source, which requires at least 1 parent element.
* @return the target as described.
*/
Path createOutputDirectoryTree(Path mediaSource) {
Path relativeParent = mediaSource.subpath(1, mediaSource.getNameCount());
Path target = cleanupSettings.getOutputBaseDirectory().resolve(relativeParent);
FileUtil.createParentDirectoriesFor(target);
return target;
}