本文整理汇总了Java中java.nio.file.Path.isAbsolute方法的典型用法代码示例。如果您正苦于以下问题:Java Path.isAbsolute方法的具体用法?Java Path.isAbsolute怎么用?Java Path.isAbsolute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.Path
的用法示例。
在下文中一共展示了Path.isAbsolute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toPathResolvingUserHome
import java.nio.file.Path; //导入方法依赖的package包/类
@Override
protected Path toPathResolvingUserHome(String pathString) {
Path homeResolvedPath = super.toPathResolvingUserHome(pathString);
if (!homeResolvedPath.isAbsolute()) {
// prepend project's directory
Project p = env.getProject();
if (p != null) {
File f = FileUtil.toFile(p.getProjectDirectory());
if (f == null) {
return homeResolvedPath;
}
Path projectPath = f.toPath();
return projectPath.resolve(homeResolvedPath);
}
}
return homeResolvedPath;
}
示例2: configure
import java.nio.file.Path; //导入方法依赖的package包/类
public void configure() throws IOException {
if (readConfig()) {
if (notBlank(name)) {
config.getConfigUser().setName(this.name);
} else if (notBlank(email)) {
config.getConfigUser().setEmail(this.email);
} else if (notBlank(root)) {
Path absolute = Paths.get(root);
if (!absolute.isAbsolute()) root = PROJECT_ROOT.resolve(root).toString();
config.getConfigCore().setProjectRoot(this.root);
} else if (notBlank(baseUrl)) {
baseUrl = baseUrl.contains("localhost") ? "http://localhost:8080/serepo" : baseUrl;
config.getConfigCore().setBaseUrl(this.baseUrl);
} else if (notBlank(project)) {
config.getConfigCore().setProjectName(this.project);
}
updateConfig();
}
}
示例3: getSuiteName
import java.nio.file.Path; //导入方法依赖的package包/类
private String getSuiteName(Description description) {
Test test = (Test) TestAttributes.get("test_object");
if (test == null) {
return "<ERROR GETTING TEST>";
}
if (test instanceof MarathonTestCase) {
try {
Path path = ((MarathonTestCase) test).getFile().toPath();
Path testPath = Constants.getMarathonDirectory(Constants.PROP_TEST_DIR).toPath();
if (!path.isAbsolute()) {
return "root";
}
Path relativePath = testPath.relativize(path);
int nameCount = relativePath.getNameCount();
StringBuilder sb = new StringBuilder("root");
for (int i = 0; i < nameCount - 1; i++) {
sb.append("::").append(relativePath.getName(i));
}
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
}
}
return "My Own Test Cases";
}
示例4: loadSource
import java.nio.file.Path; //导入方法依赖的package包/类
protected MapSource loadSource(String key, ConfigurationSection section) throws InvalidConfigurationException {
Path sourcePath = ConfigUtils.getPath(section, "path", null);
if(sourcePath != null && !sourcePath.isAbsolute()) {
sourcePath = serverRoot.resolve(sourcePath);
}
if(sourcePath == null || !Files.isDirectory(sourcePath)) {
throw new InvalidConfigurationException("Skipping '" + key + "' because it does not have a valid path");
}
final MapSource source = new MapSource(key,
sourcePath,
ConfigUtils.getUrl(section, "url", null),
section.getInt("depth", Integer.MAX_VALUE),
ImmutableSet.copyOf(ConfigUtils.getPathList(section, "only")),
ImmutableSet.copyOf(ConfigUtils.getPathList(section, "exclude")),
section.getInt("priority", 0),
section.getBoolean("global-includes", true));
logger.fine(" " + source);
return source;
}
示例5: parseRelativePath
import java.nio.file.Path; //导入方法依赖的package包/类
public static Path parseRelativePath(Node node, Path def) throws InvalidXMLException {
if(node == null) return def;
final String text = node.getValueNormalize();
try {
Path path = Paths.get(text);
if(path.isAbsolute()) {
throw new InvalidPathException(text, "Path is not relative");
}
for(Path part : path) {
if(part.toString().trim().startsWith("..")) {
throw new InvalidPathException(text, "Path contains an invalid component");
}
}
return path;
} catch(InvalidPathException e) {
throw new InvalidXMLException("Invalid relative path '" + text + "'", node, e);
}
}
示例6: parse
import java.nio.file.Path; //导入方法依赖的package包/类
public Set<RotationProviderInfo> parse(MapLibrary mapLibrary, Path dataPath, Configuration config) {
ConfigurationSection base = config.getConfigurationSection("rotation.providers.file");
if(base == null) return Collections.emptySet();
Set<RotationProviderInfo> providers = new HashSet<>();
for(String name : base.getKeys(false)) {
ConfigurationSection provider = base.getConfigurationSection(name);
Path rotationFile = Paths.get(provider.getString("path"));
if(!rotationFile.isAbsolute()) rotationFile = dataPath.resolve(rotationFile);
int priority = provider.getInt("priority", 0);
if(Files.isRegularFile(rotationFile)) {
providers.add(new RotationProviderInfo(new FileRotationProvider(mapLibrary, name, rotationFile, dataPath), name, priority));
} else if(minecraftService.getLocalServer().startup_visibility() == ServerDoc.Visibility.PUBLIC) {
// This is not a perfect way to decide whether or not to throw an error, but it's the best we can do right now
mapLibrary.getLogger().severe("Missing rotation file: " + rotationFile);
}
}
return providers;
}
示例7: run
import java.nio.file.Path; //导入方法依赖的package包/类
private static void run( String currentDir, JGrabOptions options ) throws Exception {
if ( options instanceof JGrabOptions.JavaFile ) {
JGrabOptions.JavaFile javaFile = ( JGrabOptions.JavaFile ) options;
Path rawPath = javaFile.file.toPath();
Path canonicalPath = rawPath.isAbsolute() ? rawPath : Paths.get( currentDir ).resolve( rawPath );
run( new FileJavaCode( canonicalPath ), javaFile.args );
} else if ( options instanceof JGrabOptions.StdIn ) {
run( new StdinJavaCode(), new String[ 0 ] );
} else if ( options instanceof JGrabOptions.Snippet ) {
run( new StringJavaCode( ( ( JGrabOptions.Snippet ) options ).code ), new String[ 0 ] );
} else if ( options instanceof JGrabOptions.Daemon ) {
JGrabDaemon.start( JGrabRunner::run );
} else if ( options instanceof JGrabOptions.None ) {
// nothing to do
} else {
error( "Unknown JGrab option: " + options );
}
}
示例8: load
import java.nio.file.Path; //导入方法依赖的package包/类
public void load(File dataFolder, ConfigurationSection config) {
Path localRepositoryDirectory = Paths.get(config.getString("local_repository_directory"));
if (!localRepositoryDirectory.isAbsolute())
localRepositoryDirectory = dataFolder.toPath().resolve(localRepositoryDirectory);
setLocalRepositoryDirectory(localRepositoryDirectory.toFile());
ConfigurationSection repositories = config.getConfigurationSection("repositories");
if (repositories != null) {
Map<String, Object> entries = repositories.getValues(false);
List<RemoteRepository> resultRepositories = new ArrayList<>(entries.size());
for (Map.Entry<String, Object> entry : entries.entrySet())
resultRepositories.add(readRemoteRepository(entry.getKey(), (ConfigurationSection) entry.getValue()));
setRepositories(resultRepositories);
} else {
setRepositories(Collections.emptyList());
}
}
示例9: load
import java.nio.file.Path; //导入方法依赖的package包/类
public void load(File dataFolder, Configuration config) {
Path localRepositoryDirectory = Paths.get(config.getString("local_repository_directory"));
if (!localRepositoryDirectory.isAbsolute())
localRepositoryDirectory = dataFolder.toPath().resolve(localRepositoryDirectory);
setLocalRepositoryDirectory(localRepositoryDirectory.toFile());
Configuration repositories = (Configuration) config.get("repositories");
if (repositories != null) {
Collection<String> keys = repositories.getKeys();
List<RemoteRepository> resultRepositories = new ArrayList<>(keys.size());
for (String key : keys) {
Configuration value = (Configuration) repositories.get(key);
resultRepositories.add(readRemoteRepository(key, value));
}
setRepositories(resultRepositories);
} else {
setRepositories(Collections.emptyList());
}
}
示例10: initialize
import java.nio.file.Path; //导入方法依赖的package包/类
public void initialize() throws IOException, UnirestException {
baseUrl = baseUrl.contains("localhost") ? "http://localhost:8080/serepo" : baseUrl;
Path absolute = Paths.get(source);
if (!absolute.isAbsolute()) source = PROJECT_ROOT.resolve(source).toString();
if (Files.exists(EADL_ROOT)) {
LOG.debug("EadlSync directory already exists for this project");
} else {
Files.createDirectory(EADL_ROOT);
createConfigFile(EADL_CONFIG);
}
String commitsUrl = String.format(YStatementConstants.SEREPO_URL_COMMITS, baseUrl, name);
updateCommitId(SeRepoConector.getLatestCommit(commitsUrl));
}
示例11: getConfigurationSource
import java.nio.file.Path; //导入方法依赖的package包/类
private ConfigurationSource getConfigurationSource(Path configFilePath) {
ConfigFilesProvider configFilesProvider = () ->
ImmutableList.of(configFilePath);
if (configFilePath.isAbsolute()) {
LOGGER.debug("loading config from: {}", configFilePath);
return new FilesConfigurationSource(configFilesProvider);
} else {
LOGGER.debug("loading config from classpath");
return new ClasspathConfigurationSource(configFilesProvider);
}
}
示例12: executeScript
import java.nio.file.Path; //导入方法依赖的package包/类
public void executeScript(Path sourceFile) throws Exception
{
Objects.requireNonNull(sourceFile);
if (!sourceFile.isAbsolute())
{
sourceFile = SCRIPT_FOLDER.resolve(sourceFile);
}
// throws exception if not exists or not file
checkExistingFile("ScriptFile", sourceFile);
sourceFile = sourceFile.toAbsolutePath();
final String ext = getFileExtension(sourceFile);
Objects.requireNonNull(sourceFile, "ScriptFile: " + sourceFile + " does not have an extension to determine the script engine!");
final IExecutionContext engine = getEngineByExtension(ext);
Objects.requireNonNull(engine, "ScriptEngine: No engine registered for extension " + ext + "!");
_currentExecutionContext = engine;
try
{
final Entry<Path, Throwable> error = engine.executeScript(sourceFile);
if (error != null)
{
throw new Exception("ScriptEngine: " + error.getKey() + " failed execution!", error.getValue());
}
}
finally
{
_currentExecutionContext = null;
}
}
示例13: create
import java.nio.file.Path; //导入方法依赖的package包/类
public static Path create( String first, String... more )
{
Path path = Paths.get( first, more );
if( !path.isAbsolute() )
{
// Use the "user.dir" system property because we set this property to the experiment root.
// Note there is no way to set the current working directory at the OS level in Java, so we
// must use something like this.
path = resolveRelativePath( first, more );
}
return path;
}
示例14: getPath
import java.nio.file.Path; //导入方法依赖的package包/类
private static Path getPath(OptionValues options, OptionKey<String> baseNameOption, String extension, boolean includeThreadId) throws IOException {
if (baseNameOption.getValue(options) == null) {
return null;
}
String ext = formatExtension(extension);
final String name = includeThreadId
? String.format("%s-%d_%s%s", baseNameOption.getValue(options), getGlobalTimeStamp(), getThreadDumpId(ext), ext)
: String.format("%s-%d%s", baseNameOption.getValue(options), getGlobalTimeStamp(), ext);
Path result = Paths.get(name);
if (result.isAbsolute()) {
return result;
}
Path dumpDir = DebugOptions.getDumpDirectory(options);
return dumpDir.resolve(name).normalize();
}
示例15: getJarClassPath
import java.nio.file.Path; //导入方法依赖的package包/类
public List<Path> getJarClassPath(Path file) throws IOException {
Path parent = file.getParent();
try (JarFile jarFile = new JarFile(file.toFile())) {
Manifest man = jarFile.getManifest();
if (man == null)
return Collections.emptyList();
Attributes attr = man.getMainAttributes();
if (attr == null)
return Collections.emptyList();
String path = attr.getValue(Attributes.Name.CLASS_PATH);
if (path == null)
return Collections.emptyList();
List<Path> list = new ArrayList<>();
for (StringTokenizer st = new StringTokenizer(path);
st.hasMoreTokens(); ) {
String elt = st.nextToken();
Path f = FileSystems.getDefault().getPath(elt);
if (!f.isAbsolute() && parent != null)
f = parent.resolve(f).toAbsolutePath();
list.add(f);
}
return list;
}
}