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


Java Path.toAbsolutePath方法代码示例

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


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

示例1: getDumpDirectory

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Gets the directory in which {@link DebugDumpHandler}s can generate output. This will be the
 * directory specified by {@link #DumpPath} if it has been set otherwise it will be derived from
 * the default value of {@link #DumpPath} and {@link PathUtilities#getGlobalTimeStamp()}.
 *
 * This method will ensure the returned directory exists, printing a message to {@link TTY} if
 * it creates it.
 *
 * @return a path as described above whose directories are guaranteed to exist
 * @throws IOException if there was an error in {@link Files#createDirectories}
 */
public static Path getDumpDirectory(OptionValues options) throws IOException {
    Path dumpDir;
    if (DumpPath.hasBeenSet(options)) {
        dumpDir = Paths.get(DumpPath.getValue(options));
    } else {
        dumpDir = Paths.get(DumpPath.getValue(options), String.valueOf(PathUtilities.getGlobalTimeStamp()));
    }
    dumpDir = dumpDir.toAbsolutePath();
    if (!Files.exists(dumpDir)) {
        synchronized (DebugConfigImpl.class) {
            if (!Files.exists(dumpDir)) {
                Files.createDirectories(dumpDir);
                TTY.println("Dumping debug output in %s", dumpDir.toString());
            }
        }
    }
    return dumpDir;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:DebugOptions.java

示例2: getTool

import java.nio.file.Path; //导入方法依赖的package包/类
private static String getTool(String tool, String property) throws FileNotFoundException {
    String jdkPath = System.getProperty(property);

    if (jdkPath == null) {
        throw new RuntimeException(
                "System property '" + property + "' not set. This property is normally set by jtreg. "
                + "When running test separately, set this property using '-D" + property + "=/path/to/jdk'.");
    }

    Path toolName = Paths.get("bin", tool + (isWindows() ? ".exe" : ""));

    Path jdkTool = Paths.get(jdkPath, toolName.toString());
    if (!jdkTool.toFile().exists()) {
        throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath());
    }

    return jdkTool.toAbsolutePath().toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:JDKToolFinder.java

示例3: prepareFile

import java.nio.file.Path; //导入方法依赖的package包/类
private void prepareFile(String path) throws SLException {
    MtaPathValidator.validatePath(path);
    Path source = mtaDir.resolve(path);
    if (Files.notExists(source)) {
        throw new SLException(Messages.PATH_IS_RESOLVED_TO_NOT_EXISTING_FILE, path, source.toAbsolutePath());
    }
    try {
        Path target = mtaAssemblyDir.resolve(path);
        if (Files.isDirectory(source)) {
            FileUtils.copyDirectory(source, target);
        } else {
            FileUtils.copyFile(source, target);
        }
        jarEntries.add(target);
    } catch (IOException e) {
        throw new SLException(e, Messages.FAILED_TO_COPY_FILE_0_TO_ASSEMBLY_DIRECTORY, source.toAbsolutePath());
    }
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:19,代码来源:MtaArchiveBuilder.java

示例4: getTool

import java.nio.file.Path; //导入方法依赖的package包/类
private static String getTool(String tool, String property) throws FileNotFoundException {
    String jdkPath = System.getProperty(property);

    if (jdkPath == null) {
        throw new RuntimeException(
                "System property '" + property + "' not set. This property is normally set by jtreg. "
                + "When running test separately, set this property using '-D" + property + "=/path/to/jdk'.");
    }

    Path toolName = Paths.get("bin", tool + (Platform.isWindows() ? ".exe" : ""));

    Path jdkTool = Paths.get(jdkPath, toolName.toString());
    if (!jdkTool.toFile().exists()) {
        throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath());
    }

    return jdkTool.toAbsolutePath().toString();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:JDKToolFinder.java

示例5: writePreferences

import java.nio.file.Path; //导入方法依赖的package包/类
private Path writePreferences() {
    try {
        final Path preferences = Files.createTempFile("goal-prefs", ".yml");

        // CHECKSTYLE OFF
        // TODO: make this dynamic
        // CHECKSTYLE ON
        try (InputStream in  = this.getClass().getResourceAsStream("/temp/prefs.yml");
             OutputStream out = Files.newOutputStream(preferences)) {
            final byte[] buffer = new byte[8192];
            while (true) {
                int size = in.read(buffer);

                if (size < 0) {
                    break;
                }

                out.write(buffer, 0, size);
            }
        }

        return preferences.toAbsolutePath();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:ceddy4395,项目名称:Goal-Intellij-Plugin,代码行数:27,代码来源:GoalRunConfiguration.java

示例6: addComment

import java.nio.file.Path; //导入方法依赖的package包/类
@Override
public InternalIssueVerifier addComment(Path path, int line, int column, String content, int prefixLength, int suffixLength) {
  Path absolutePath = path.toAbsolutePath();
  filesToVerify.add(absolutePath);
  int contentColumn = column + prefixLength;
  String commentContent = content.substring(prefixLength, content.length() - suffixLength);
  comments.computeIfAbsent(absolutePath, key -> new ArrayList<>())
    .add(new Comment(absolutePath, line, column, contentColumn, commentContent));
  return this;
}
 
开发者ID:SonarSource,项目名称:sonar-analyzer-commons,代码行数:11,代码来源:InternalIssueVerifier.java

示例7: reportIssue

import java.nio.file.Path; //导入方法依赖的package包/类
@Override
public InternalIssue reportIssue(Path path, String message) {
  Path absolutePath = path.toAbsolutePath();
  filesToVerify.add(absolutePath);
  InternalIssue issue = new InternalIssue(absolutePath, message);
  actualIssues.computeIfAbsent(absolutePath, key -> new ArrayList<>()).add(issue);
  return issue;
}
 
开发者ID:SonarSource,项目名称:sonar-analyzer-commons,代码行数:9,代码来源:InternalIssueVerifier.java

示例8: ActionHelper

import java.nio.file.Path; //导入方法依赖的package包/类
public ActionHelper(Path workDir, String prefix, Properties properties,
                    Path... jdks) throws InvalidValueException {
    this.workDir = workDir.toAbsolutePath();
    getChildren = new PatternAction("children",
            Utils.prependPrefix(prefix, "getChildren"), properties);
    ValueHandler.apply(this, properties, prefix);
    String[] pathStrings = System.getenv("PATH").split(File.pathSeparator);
    paths = new Path[pathStrings.length];
    for (int i = 0; i < paths.length; ++i) {
        paths[i] = Paths.get(pathStrings[i]);
    }
    addJdks(jdks);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ActionHelper.java

示例9: parse

import java.nio.file.Path; //导入方法依赖的package包/类
public static ClientYamlTestSuite parse(String api, Path file) throws IOException {
    if (!Files.isRegularFile(file)) {
        throw new IllegalArgumentException(file.toAbsolutePath() + " is not a file");
    }

    String filename = file.getFileName().toString();
    //remove the file extension
    int i = filename.lastIndexOf('.');
    if (i > 0) {
        filename = filename.substring(0, i);
    }

    //our yaml parser seems to be too tolerant. Each yaml suite must end with \n, otherwise clients tests might break.
    try (FileChannel channel = FileChannel.open(file, StandardOpenOption.READ)) {
        ByteBuffer bb = ByteBuffer.wrap(new byte[1]);
        channel.read(bb, channel.size() - 1);
        if (bb.get(0) != 10) {
            throw new IOException("test suite [" + api + "/" + filename + "] doesn't end with line feed (\\n)");
        }
    }

    try (XContentParser parser = YamlXContent.yamlXContent.createParser(ExecutableSection.XCONTENT_REGISTRY,
            Files.newInputStream(file))) {
        return parse(api, filename, parser);
    } catch(Exception e) {
        throw new IOException("Error parsing " + api + "/" + filename, e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:ClientYamlTestSuite.java

示例10: toCanonicalPath

import java.nio.file.Path; //导入方法依赖的package包/类
private final static Path toCanonicalPath(final Path path) {
	try {
		return path.toFile().getCanonicalFile().toPath();
	} catch (final IOException e) {
		return path.toAbsolutePath();
	}
}
 
开发者ID:Njol,项目名称:Motunautr,代码行数:8,代码来源:FileWatcher.java

示例11: findIncludeFile

import java.nio.file.Path; //导入方法依赖的package包/类
private @Nullable Path findIncludeFile(@Nullable Path basePath, Path includeFile, @Nullable Element includeElement) throws InvalidXMLException {
    Iterable<Path> includePaths = mapConfiguration.includePaths();
    if(basePath != null) {
        includePaths = Iterables.concat(includePaths, Collections.singleton(basePath));
    }

    for(Path includePath : includePaths) {
        Path fullPath = includePath.resolve(includeFile);
        if(Files.isRegularFile(fullPath)) {
            return fullPath.toAbsolutePath();
        }
    }

    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:16,代码来源:MapFilePreprocessor.java

示例12: watch

import java.nio.file.Path; //导入方法依赖的package包/类
@Override
public PathWatcherHandle watch(Path path, Executor executor, PathWatcher callback) throws IOException {
    path = path.toAbsolutePath();
    if(path.getNameCount() == 0) {
        throw new IllegalArgumentException("Cannot watch the root directory");
    }
    return watchedDirs.getUnchecked(path.getParent()).new WatchedPath(path, executor, callback);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:PathWatcherServiceImpl.java

示例13: createJupyterTempFolder

import java.nio.file.Path; //导入方法依赖的package包/类
static Path createJupyterTempFolder() {
  Path ret = null;
  try {
    ret = Files.createTempDirectory("beaker");
  } catch (IOException e) {
    logger.error("No temp folder set for beaker", e);
  }
  return ret.toAbsolutePath();
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:10,代码来源:Evaluator.java

示例14: generateJavaPackageStructure

import java.nio.file.Path; //导入方法依赖的package包/类
public static Path generateJavaPackageStructure(final Path start, final String packageName) throws IOException {
    final String[] subFolders = packageName.split("\\.");
    Path path = start.toAbsolutePath();
    for (String folder : subFolders) {
        path = path.resolve(folder);
    }
    Files.createDirectories(path);
    return path;
}
 
开发者ID:btc-ag,项目名称:redg,代码行数:10,代码来源:FileUtils.java

示例15: RemoteMount

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Creates a new instance.
 *
 * @param remoteBasePath the remote base path.
 * @param localBasePath the local base path. If not absolute, we make it
 * such. So in general you should probably pass in an absolute path!
 * @throws NullPointerException if any argument is {@code null}.
 * @throws IllegalArgumentException if the remote base path is not that of
 * a {@link #isRemoteFilePath(URI) remote file path}.
 */
public RemoteMount(URI remoteBasePath, Path localBasePath) {
    requireNonNull(remoteBasePath, "remoteBasePath");
    requireNonNull(localBasePath, "localBasePath");
    if (!isRemoteFilePath(remoteBasePath)) {
        throw new IllegalArgumentException(
            String.format("not a remote file path: %s", remoteBasePath));
    }

    this.remoteBasePath = remoteBasePath;
    this.localBasePath = localBasePath.toAbsolutePath();
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:22,代码来源:RemoteMount.java


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