本文整理了Java中org.kie.commons.java.nio.file.Path.relativize()
方法的一些代码示例,展示了Path.relativize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.relativize()
方法的具体详情如下:
包路径:org.kie.commons.java.nio.file.Path
类名称:Path
方法名:relativize
暂无
代码示例来源:origin: org.kie.guvnor/guvnor-project-backend
final org.kie.commons.java.nio.file.Path nioDelta = nioProjectPath.relativize( nioPackagePath );
代码示例来源:origin: org.kie.guvnor/guvnor-workitems-editor-backend
private List<String> loadWorkItemImages( final Path resourcePath ) {
final Path projectRoot = projectService.resolveProject( resourcePath );
final org.kie.commons.java.nio.file.Path nioProjectPath = paths.convert( projectRoot );
final org.kie.commons.java.nio.file.Path nioResourceParent = paths.convert( resourcePath ).getParent();
final Collection<org.kie.commons.java.nio.file.Path> imagePaths = fileDiscoveryService.discoverFiles( nioProjectPath,
imageFilter,
true );
final List<String> images = new ArrayList<String>();
for ( org.kie.commons.java.nio.file.Path imagePath : imagePaths ) {
final org.kie.commons.java.nio.file.Path relativePath = nioResourceParent.relativize( imagePath );
images.add( relativePath.toString() );
}
return images;
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-project-backend
org.kie.commons.java.nio.file.Path packagePath = null;
if ( nioResource.startsWith( nioMainSrcPath ) ) {
packagePath = nioMainSrcPath.relativize( nioResource );
packageName = packagePath.toString().replaceAll( "/",
"." );
} else if ( nioResource.startsWith( nioTestSrcPath ) ) {
packagePath = nioTestSrcPath.relativize( nioResource );
packageName = packagePath.toString().replaceAll( "/",
"." );
} else if ( nioResource.startsWith( nioMainResourcesPath ) ) {
packagePath = nioMainResourcesPath.relativize( nioResource );
packageName = packagePath.toString().replaceAll( "/",
"." );
} else if ( nioResource.startsWith( nioTestResourcesPath ) ) {
packagePath = nioTestResourcesPath.relativize( nioResource );
packageName = packagePath.toString().replaceAll( "/",
"." );
代码示例来源:origin: org.kie.commons/kie-nio2-api
public static Path createDirectories( final Path dir,
final FileAttribute<?>... attrs )
throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
checkNotNull( "dir", dir );
final Path absoluteDir = dir.toAbsolutePath();
if ( !notExists( absoluteDir ) ) {
throw new FileAlreadyExistsException( absoluteDir.toString() );
}
Path parent = absoluteDir.getParent();
while ( parent != null ) {
try {
providerOf( parent ).checkAccess( parent );
break;
} catch ( NoSuchFileException x ) {
}
parent = parent.getParent();
}
if ( parent == null ) {
throw new IOException( "Root directory does not exist" );
}
// create directories
Path child = parent;
for ( final Path name : parent.relativize( dir ) ) {
child = child.resolve( name );
providerOf( child ).createDirectory( child, attrs );
}
return dir;
}
代码示例来源:origin: org.kie.commons/kie-nio2-jgit
final Path relative = path.relativize(other);
assertThat(relative).isNotNull();
assertThat(relative.toString()).isEqualTo("some/place");
final Path relative2 = path2.relativize(other2);
assertThat(relative2).isNotNull();
assertThat(relative2.toString()).isEqualTo("../..");
final Path relative3 = path3.relativize(other3);
assertThat(relative3).isNotNull();
assertThat(relative3.toString()).isEqualTo("");
final Path relative4 = path4.relativize(other4);
assertThat(relative4).isNotNull();
assertThat(relative4.toString()).isEqualTo("some/place");
final Path relative5 = path5.relativize(other5);
assertThat(relative5).isNotNull();
assertThat(relative5.toString()).isEqualTo("../../some/place");
final Path relative6 = path6.relativize(other6);
assertThat(relative6).isNotNull();
assertThat(relative6.toString()).isEqualTo("../../path/to");
final Path relative7 = path7.relativize(other7);
assertThat(relative7).isNotNull();
assertThat(relative7.toString()).isEqualTo("../../../../../some/place");
final Path relative8 = path8.relativize(other8);
内容来源于网络,如有侵权,请联系作者删除!