当前位置: 首页>>代码示例>>Java>>正文


Java Path.normalize方法代码示例

本文整理汇总了Java中java.nio.file.Path.normalize方法的典型用法代码示例。如果您正苦于以下问题:Java Path.normalize方法的具体用法?Java Path.normalize怎么用?Java Path.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.file.Path的用法示例。


在下文中一共展示了Path.normalize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DriveStorage

import java.nio.file.Path; //导入方法依赖的package包/类
public DriveStorage(Path workingDir, ImageDB imgDB, Predicate<StoreImage> storageRule) {
	if (workingDir == null) {
		log.error("The supplied working directory is null.");
		throw new NullPointerException("The supplied working directory is null.");
	}
	if (imgDB == null) {
		log.error("The supplied image database is null.");
		throw new NullPointerException("The supplied image database is null.");
	}
	if (storageRule == null) {
		log.error("The supplied rule to determine if an image can be stored is null.");
		throw new NullPointerException("The supplied rule to determine if an image can be stored is null.");
	}
	
	this.workingDir = workingDir.normalize();
	this.imgDB = imgDB;
	this.storageRule = storageRule;
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:19,代码来源:DriveStorage.java

示例2: getDataDirPath

import java.nio.file.Path; //导入方法依赖的package包/类
/** Get 'data' folder path. **/
public static Path getDataDirPath() {
	if(dataDirPath != null) {
		return dataDirPath;
	}
	Path path = getRootDirPath();
	if (debugBuild) {
		path = path.resolve("build");
	}
	path = path.resolve("data");
	if (!Files.isDirectory(path)) {
		path.toFile().mkdir();
		log("Created directory: " + path);
	}
	dataDirPath = path.normalize();
	return dataDirPath;
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:18,代码来源:PluginManager.java

示例3: getRootDirPath

import java.nio.file.Path; //导入方法依赖的package包/类
/** Get DeskChan folder path. **/
public static Path getRootDirPath() {
	if(rootDirPath != null) {
		return rootDirPath;
	}
	Path corePath = getCorePath();
	Path path;
	if (debugBuild) {
		path = corePath;
		try {
               while (!IsPathEndsWithList(path,debugBuildFolders))
				path = path.getParent();
			path = path.getParent();
		} catch (Exception e){
			log("Error while locating root path with path: "+corePath);
		}
	} else {
		path = corePath.getParent().resolve("../");
	}
	rootDirPath = path.normalize();
	return rootDirPath;
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:23,代码来源:PluginManager.java

示例4: get

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Tries to resolve the given path against the list of available roots.
 *
 * If path starts with one of the listed roots, it returned back by this method, otherwise null is returned.
 */
public static Path get(Path[] roots, String path) {
    for (Path root : roots) {
        Path normalizedRoot = root.normalize();
        Path normalizedPath = normalizedRoot.resolve(path).normalize();
        if(normalizedPath.startsWith(normalizedRoot)) {
            return normalizedPath;
        }
    }
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:PathUtils.java

示例5: getAbsolutePath

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Calcul le chemin absolu d'un chemin relatif à un chemin absolu.
 * 
 * @param absoluteFilePath Chemin absolu de référence.
 * @param relativeFilePath Chemin relatif.
 * @return Chemin absolu du chemin relatif.
 */
public static String getAbsolutePath(String absoluteFilePath, String relativeFilePath) {
	try {
		Path basePath = FileSystems.getDefault().getPath(absoluteFilePath); // NOSONAR
		Path resolvedPath = basePath.getParent().resolve(relativeFilePath);
		Path absolutePath = resolvedPath.normalize();
		return absolutePath.toString();
	} catch (IllegalArgumentException e) { // NOSONAR
		/* Erreur à la construction du fichier : on sort. */
		return null;
	}
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:19,代码来源:FileUtils.java

示例6: toJarEntryName

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Map a file path to the equivalent name in a JAR file
 */
static String toJarEntryName(Path file) {
    Path normalized = file.normalize();
    return normalized.subpath(0, normalized.getNameCount())
            .toString()
            .replace(File.separatorChar, '/');
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Main.java

示例7: toJarEntryName

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Map a file path to the equivalent name in a JAR file
 */
private static String toJarEntryName(Path file) {
    Path normalized = file.normalize();
    return normalized.subpath(0, normalized.getNameCount())  // drop root
            .toString()
            .replace(File.separatorChar, '/');
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:JarUtils.java

示例8: createJarFile

import java.nio.file.Path; //导入方法依赖的package包/类
public static Path createJarFile(Path jarfile, Path dir, Path file) throws IOException {
    // create the target directory
    Path parent = jarfile.getParent();
    if (parent != null)
        Files.createDirectories(parent);

    List<Path> entries = Files.find(dir.resolve(file), Integer.MAX_VALUE,
            (p, attrs) -> attrs.isRegularFile())
            .map(dir::relativize)
            .collect(Collectors.toList());

    try (OutputStream out = Files.newOutputStream(jarfile);
         JarOutputStream jos = new JarOutputStream(out)) {
        for (Path entry : entries) {
            // map the file path to a name in the JAR file
            Path normalized = entry.normalize();
            String name = normalized
                    .subpath(0, normalized.getNameCount())  // drop root
                    .toString()
                    .replace(File.separatorChar, '/');

            jos.putNextEntry(new JarEntry(name));
            Files.copy(dir.resolve(entry), jos);
        }
    }
    return jarfile;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:JImageGenerator.java

示例9: get

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Tries to resolve the given path against the list of available roots.
 * <p>
 * If path starts with one of the listed roots, it returned back by this method, otherwise null is returned.
 */
public static Path get(Path[] roots, String path) {
    for (Path root : roots) {
        Path normalizedRoot = root.normalize();
        Path normalizedPath = normalizedRoot.resolve(path).normalize();
        if (normalizedPath.startsWith(normalizedRoot)) {
            return normalizedPath;
        }
    }
    return null;
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:16,代码来源:PathUtils.java

示例10: getPluginsDirPath

import java.nio.file.Path; //导入方法依赖的package包/类
/** Get 'plugins' folder path. **/
public static Path getPluginsDirPath() {
	if(pluginsDirPath != null) {
		return pluginsDirPath;
	}
	Path path = getRootDirPath();
	if (debugBuild) {
		path = path.resolve("build").resolve("launch4j");
	}
	path = path.resolve("plugins");
	pluginsDirPath = path.normalize();
	return pluginsDirPath;
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:14,代码来源:PluginManager.java

示例11: getAssetsDirPath

import java.nio.file.Path; //导入方法依赖的package包/类
/** Get 'assets' folder path. **/
public static Path getAssetsDirPath() {
	if(assetsDirPath != null) {
		return assetsDirPath;
	}
	Path path = getRootDirPath();
	path = path.resolve("assets");
	if (!Files.isDirectory(path)) {
		path.toFile().mkdir();
		log("Created directory: " + path);
	}
	assetsDirPath = path.normalize();
	return assetsDirPath;
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:15,代码来源:PluginManager.java

示例12: PathEntry

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * @param root path entry root
 * @throws NullPointerException if {@code root} is {@code null}
 */
protected PathEntry(Path root) {
    Objects.requireNonNull(root, "root can not be null");
    this.root = root.normalize();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:PathHandler.java


注:本文中的java.nio.file.Path.normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。