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


Java Path.resolveSibling方法代码示例

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


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

示例1: saveMatches

import java.nio.file.Path; //导入方法依赖的package包/类
private void saveMatches() {
	Path path = Gui.requestFile("Save matches file", gui.getScene().getWindow(), Arrays.asList(new FileChooser.ExtensionFilter("Matches", "*.match")), false);
	if (path == null) return;

	if (!path.getFileName().toString().toLowerCase(Locale.ENGLISH).endsWith(".match")) {
		path = path.resolveSibling(path.getFileName().toString()+".match");
	}

	try {
		if (Files.isDirectory(path)) {
			gui.showAlert(AlertType.ERROR, "Save error", "Invalid file selection", "The selected file is a directory.");
		} else if (Files.exists(path)) {
			Files.deleteIfExists(path);
		}

		if (!gui.getMatcher().saveMatches(path)) {
			gui.showAlert(AlertType.WARNING, "Matches save warning", "No matches to save", "There are currently no matched classes, so saving was aborted.");
		}
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return;
	}
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:25,代码来源:FileMenu.java

示例2: getUnique

import java.nio.file.Path; //导入方法依赖的package包/类
private static Path getUnique(Path target) {
    String fileName = target.getFileName().toString();
    String name = com.google.common.io.Files.getNameWithoutExtension(fileName);
    String ext = com.google.common.io.Files.getFileExtension(fileName);
    if (!ext.equals("")) {
        ext = "." + ext;
    }
    while (!Files.notExists(target)) {
        Matcher matcher = pattern2.matcher(name);
        if (matcher.matches()) {
            name = matcher.group(1) + "_copy_" + (Integer.parseInt(matcher.group(2)) + 1);
        } else {
            matcher = pattern1.matcher(name);
            if (matcher.matches()) {
                name = matcher.group(1) + "_copy_2";
            } else {
                name = name + "_copy";
            }

        }
        target = target.resolveSibling(name + ext);
    }
    return target;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:Copy.java

示例3: hasNotCompanionFile

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Tests whether the given file has not another file named with the {@link #whileSkippingExtraFilesWith(String)}
 * extension. E.g. if both files "foo/bar" and "foo/bar.skipping" exist, then this method returns false,
 * otherwise true.
 *
 * @param path the base file name.
 * @return false if there is a companion file, true if the companion file does not exist or the extension is not
 * specified.
 */
boolean hasNotCompanionFile(Path path) {
    if (skipExtension.isPresent()) {
        Path sibling = path.resolveSibling(path.getFileName() + skipExtension.get());
        boolean companionFileExists = Files.exists(sibling);
        boolean markDirFileExists = skipDirectory.map(dir -> {
            Path siblingInDir = searchDir.get().getParent().relativize(sibling);
            Path toChck = dir.resolve(siblingInDir);
            return Files.exists(toChck);
        }).orElse(false);
        if (companionFileExists || markDirFileExists) log.debug("Ignoring: {}", path);
        return !(companionFileExists || markDirFileExists);
    } else {
        return true;
    }
}
 
开发者ID:ccremer,项目名称:clustercode,代码行数:25,代码来源:FileScannerImpl.java

示例4: processRename

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * The process of renaming.
 */
private void processRename(@NotNull final String newFileName) {

    final Path file = getElement().getFile();

    final String extension = FileUtils.getExtension(file);
    final String resultName = StringUtils.isEmpty(extension) ? newFileName : newFileName + "." + extension;

    final Path newFile = file.resolveSibling(resultName);

    try {
        Files.move(file, newFile);
    } catch (final IOException e) {
        EditorUtil.handleException(null, this, e);
        return;
    }

    final RenamedFileEvent event = new RenamedFileEvent();
    event.setNewFile(newFile);
    event.setPrevFile(file);

    FX_EVENT_MANAGER.notify(event);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:RenameFileAction.java

示例5: loadSatelliteImages

import java.nio.file.Path; //导入方法依赖的package包/类
private void loadSatelliteImages(PhotoLocationExercise exercise, Path exercisePath, Boolean dryRun) throws IOException, BuenOjoCSVParserException, InvalidSatelliteImageType, BuenOjoFileException, BuenOjoInconsistencyException, BuenOjoDataSetException{
	List<Path> satelliteImagePaths = Files.walk(exercisePath, 1, FileVisitOption.FOLLOW_LINKS).filter(p -> {
		Optional<String> type = BuenOjoFileUtils.contentType(p);
		return type.isPresent() && type.get() != "text/csv";
	}).collect(Collectors.toList());
	
	List<SatelliteImage> satelliteImages = new ArrayList<>();
	for (Path path : satelliteImagePaths) {
		String filename = FilenameUtils.removeExtension(path.getFileName().toString());
		Path csv = path.resolveSibling(filename+".csv");
		SatelliteImage s = satelliteImageFactory.imageFromFile(BuenOjoFileUtils.multipartFile(path), BuenOjoFileUtils.multipartFile(csv), dryRun);
		satelliteImages.add(s);
	}
	satelliteImageRepository.save(satelliteImages);
	
	List<PhotoLocationSatelliteImage> pImages = new ArrayList<>();
	
	for (SatelliteImage satelliteImage : satelliteImages) {
		PhotoLocationSatelliteImage pImg = PhotoLocationSatelliteImage.fromSatelliteImage(satelliteImage);
		pImg.setKeywords(exercise.getLandscapeKeywords());
		pImages.add(pImg);
		
	}
	
	photoLocationSatelliteImageRepository.save(pImages);
	
	exercise.setSatelliteImages(new HashSet<>(pImages));
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:29,代码来源:PhotoLocationLoader.java

示例6: upgrade

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Renames <code>indexFolderName</code> index folders found in node paths and custom path
 * iff {@link #needsUpgrade(Index, String)} is true.
 * Index folder in custom paths are renamed first followed by index folders in each node path.
 */
void upgrade(final String indexFolderName) throws IOException {
    for (NodeEnvironment.NodePath nodePath : nodeEnv.nodePaths()) {
        final Path indexFolderPath = nodePath.indicesPath.resolve(indexFolderName);
        final IndexMetaData indexMetaData = IndexMetaData.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, indexFolderPath);
        if (indexMetaData != null) {
            final Index index = indexMetaData.getIndex();
            if (needsUpgrade(index, indexFolderName)) {
                logger.info("{} upgrading [{}] to new naming convention", index, indexFolderPath);
                final IndexSettings indexSettings = new IndexSettings(indexMetaData, settings);
                if (indexSettings.hasCustomDataPath()) {
                    // we rename index folder in custom path before renaming them in any node path
                    // to have the index state under a not-yet-upgraded index folder, which we use to
                    // continue renaming after a incomplete upgrade.
                    final Path customLocationSource = nodeEnv.resolveBaseCustomLocation(indexSettings)
                        .resolve(indexFolderName);
                    final Path customLocationTarget = customLocationSource.resolveSibling(index.getUUID());
                    // we rename the folder in custom path only the first time we encounter a state
                    // in a node path, which needs upgrading, it is a no-op for subsequent node paths
                    if (Files.exists(customLocationSource) // might not exist if no data was written for this index
                        && Files.exists(customLocationTarget) == false) {
                        upgrade(index, customLocationSource, customLocationTarget);
                    } else {
                        logger.info("[{}] no upgrade needed - already upgraded", customLocationTarget);
                    }
                }
                upgrade(index, indexFolderPath, indexFolderPath.resolveSibling(index.getUUID()));
            } else {
                logger.debug("[{}] no upgrade needed - already upgraded", indexFolderPath);
            }
        } else {
            logger.warn("[{}] no index state found - ignoring", indexFolderPath);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:IndexFolderUpgrader.java

示例7: metadataPath

import java.nio.file.Path; //导入方法依赖的package包/类
private Path metadataPath(Path dataPath) {
    String filename = dataPath.getFileName().toString();
    StringBuilder builder = new StringBuilder(filename);
    builder.setLength(builder.length() - dataSuffix.length());
    builder.append(metadataSuffix);
    return dataPath.resolveSibling(builder.toString());
}
 
开发者ID:tim-group,项目名称:tg-eventstore,代码行数:8,代码来源:FlatFilesystemEventReader.java

示例8: doProcessStep

import java.nio.file.Path; //导入方法依赖的package包/类
@Override
protected CleanupContext doProcessStep(CleanupContext context) {
    Path source = getSourcePath(context);

    Path marked = source.resolveSibling(source.getFileName().toString() + mediaScanSettings.getSkipExtension());

    createMarkFile(marked, source);
    return context;
}
 
开发者ID:ccremer,项目名称:clustercode,代码行数:10,代码来源:MarkSourceProcessor.java

示例9: generateJAXPProps

import java.nio.file.Path; //导入方法依赖的package包/类
static void generateJAXPProps(String content) throws IOException {
    Path filePath = getJAXPPropsPath();
    Path bakPath = filePath.resolveSibling(JAXP_PROPS_BAK);
    System.out.println("Creating new file " + filePath +
        ", saving old version to " + bakPath + ".");
    if (Files.exists(filePath) && !Files.exists(bakPath)) {
        Files.move(filePath, bakPath);
    }

    Files.write(filePath, content.getBytes());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:CatalogTestUtils.java

示例10: deleteJAXPProps

import java.nio.file.Path; //导入方法依赖的package包/类
static void deleteJAXPProps() throws IOException {
    Path filePath = getJAXPPropsPath();
    Path bakPath = filePath.resolveSibling(JAXP_PROPS_BAK);
    System.out.println("Removing file " + filePath +
            ", restoring old version from " + bakPath + ".");
    Files.delete(filePath);
    if (Files.exists(bakPath)) {
        Files.move(bakPath, filePath);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:CatalogTestUtils.java

示例11: jmodTempFilePath

import java.nio.file.Path; //导入方法依赖的package包/类
private static Path jmodTempFilePath(Path target) throws IOException {
    return target.resolveSibling("." + target.getFileName() + ".tmp");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:JmodTask.java

示例12: getTimestampedPath

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Creates a timestamped path from the given base file. Example: "/path/basefile.ext" becomes
 * "/path/basefile.2017-01-23.14-34-20.ext" if the given timestamp equals to "2017-01-23.14-34-20".
 *
 * @param baseFile           the base name.
 * @param formattedTimestamp the pre-formatted timestamp. A leading dot will be added automatically.
 * @return a new path which has a timestamp in its filename.
 * @throws java.nio.file.InvalidPathException if the path cannot be constructed from the given string.
 */
public static Path getTimestampedPath(Path baseFile, String formattedTimestamp) {
    String ext = getFileExtension(baseFile);
    String timestamp = ".".concat(formattedTimestamp);
    return baseFile.resolveSibling(getFileNameWithoutExtension(baseFile)
            .concat(timestamp).concat(ext));
}
 
开发者ID:ccremer,项目名称:clustercode,代码行数:16,代码来源:FileUtil.java

示例13: getChecksumFile

import java.nio.file.Path; //导入方法依赖的package包/类
/**
 * Returns file which holds checksum information for given file.
 *
 * @param file to load checksum for.
 * @return checksum file.
 */
private static Path getChecksumFile(Path file) {
    return file.resolveSibling(file.getFileName().toString() + CHECKSUM_EXT);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:10,代码来源:FileChecksumHelper.java


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