本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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, '/');
}
示例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, '/');
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}