List of usage examples for java.nio.file Path toString
String toString();
From source file:edu.cmu.tetrad.cli.search.FgscCli.java
@Override public List<DataValidation> getDataValidations(DataSet dataSet, Path dirOut, String filePrefix) { List<DataValidation> validations = new LinkedList<>(); String outputDir = dirOut.toString(); if (!skipUniqueVarName) { if (validationOutput) { validations.add(new UniqueVariableNames(dataSet, Paths.get(outputDir, filePrefix + "_duplicate_var_name.txt"))); } else {//from w w w . ja v a 2s . c o m validations.add(new UniqueVariableNames(dataSet)); } } if (!skipZeroVariance) { if (validationOutput) { validations.add(new NonZeroVariance(dataSet, numOfThreads, Paths.get(outputDir, filePrefix + "_zero_variance.txt"))); } else { validations.add(new NonZeroVariance(dataSet, numOfThreads)); } } return validations; }
From source file:com.movilizer.mds.webservice.services.MafManagementService.java
protected MafCliMetaFile readMetaFile(File sourceFile) throws FileNotFoundException { String metaFileName = sourceFile.getName().replace(GROOVY_EXTENSION, META_FILE_EXTENSION); Path metaFilePath = sourceFile.toPath().resolveSibling(metaFileName); if (logger.isDebugEnabled()) { logger.debug(String.format(Messages.LOADING_MAF_METADATA, metaFilePath.toString())); }// ww w . j ava2 s . co m return gson.fromJson(new FileReader(metaFilePath.toFile()), MafCliMetaFile.class); }
From source file:at.tfr.securefs.module.scan.IKScanServiceModule.java
@Override public ModuleResult apply(InputStream is, ModuleConfiguration moduleConfiguration) throws ModuleException { Path filePath = configuration.getTmpPath().resolve("scanFile_" + UUID.randomUUID()); try {//from w ww . j a va 2 s . c o m try { Files.copy(is, filePath); return apply(filePath.toString(), moduleConfiguration); } finally { Files.deleteIfExists(filePath); } } catch (ModuleException me) { throw me; } catch (Exception e) { throw new ModuleException("cannot process", e); } }
From source file:com.googlesource.gerrit.plugins.rabbitmq.config.PluginProperties.java
@Override public String getName() { if (propertiesFile != null) { Path path = propertiesFile.getFileName(); if (path != null) { return FilenameUtils.removeExtension(path.toString()); }//from w w w .ja va 2 s . c o m } return null; }
From source file:org.mayocat.theme.internal.DefaultThemeManager.java
private Optional<Path> getClasspathThemePath(String themeId) { Path themePath = Paths.get(THEMES_FOLDER_NAME).resolve(themeId); try {//from ww w. j ava 2s .c o m Resources.getResource(themePath.toString()); return Optional.of(themePath); } catch (IllegalArgumentException e) { return Optional.absent(); } }
From source file:org.apache.jena.osgi.test.JenaOSGITest.java
@Test public void testJenaTdb() throws Exception { Path tdbDir = Files.createTempDirectory("jena-tdb-test"); Dataset dataset = TDBFactory.createDataset(tdbDir.toString()); dataset.begin(ReadWrite.WRITE);//from ww w.j a v a 2s .com dataset.addNamedModel(EXAMPLE_COM_GRAPH, makeModel()); dataset.commit(); dataset.end(); dataset.begin(ReadWrite.READ); runQuery(dataset); dataset.end(); }
From source file:at.ac.univie.isc.asio.platform.FileSystemConfigStore.java
@Override public Map<String, ByteSource> findAllWithIdentifier(final String identifier) throws DataAccessException { final FindFiles collector = FindFiles.filter(filesWithIdentifier(identifier)); Map<String, ByteSource> found = new HashMap<>(); try {//from w w w .ja va2 s . c o m log.debug(Scope.SYSTEM.marker(), "searching items with identifier <{}>", identifier); lock(); Files.walkFileTree(root, EnumSet.noneOf(FileVisitOption.class), 1, collector); for (final Path path : collector.found()) { log.debug(Scope.SYSTEM.marker(), "found <{}>", path); final Path fileName = path.getFileName(); final String[] parts = fileName.toString().split("\\#\\#"); found.put(parts[0], asByteSource(path.toFile())); } } catch (IOException e) { throw new FileSystemAccessFailure("finding items of type <" + identifier + "> failed", e); } finally { lock.unlock(); } return ImmutableMap.copyOf(found); }
From source file:com.microsoft.azure.util.TokenCache.java
private TokenCache(final AzureCredentials.ServicePrincipal servicePrincipal) { LOGGER.log(Level.FINEST, "TokenCache: TokenCache: Instantiate new cache manager"); this.credentials = servicePrincipal; // Compute the cloud name String cloudName = "<unknown"; if (credentials != null) cloudName = AzureUtil.getCloudName(credentials.subscriptionId.getPlainText()); final String home = Jenkins.getInstance().root.getPath(); LOGGER.log(Level.FINEST, "TokenCache: TokenCache: Cache home \"{0}\"", home); // Present the cloud name to the token file (rather than just simply the // subscription id because the same subscription id could be used between // classic and v2 plugins. Path homePath = Paths.get(home, String.format("%s-%s", cloudName, "azuretoken.txt")); this.path = homePath.toString(); LOGGER.log(Level.FINEST, "TokenCache: TokenCache: Cache file path \"{0}\"", path); }
From source file:com.sonar.javascript.it.plugin.SonarLintTest.java
private ClientInputFile createInputFile(final Path path, final boolean isTest) { return new ClientInputFile() { @Override//from w w w. ja v a2s . c om public String getPath() { return path.toString(); } @Override public boolean isTest() { return isTest; } @Override public Charset getCharset() { return StandardCharsets.UTF_8; } @Override public <G> G getClientObject() { return null; } @Override public String contents() throws IOException { return new String(Files.readAllBytes(path), StandardCharsets.UTF_8); } @Override public InputStream inputStream() throws IOException { return Files.newInputStream(path); } }; }
From source file:com.google.cloud.runtimes.builder.buildsteps.docker.StageDockerArtifactBuildStep.java
private Path searchForArtifactInDir(Path directory) throws ArtifactNotFoundException, TooManyArtifactsException, IOException { logger.info("Searching for a deployable artifact in {}", directory.toString()); if (!Files.isDirectory(directory)) { throw new IllegalArgumentException(String.format("%s is not a valid directory.", directory)); }//from www . ja va 2 s.c o m List<Path> validArtifacts = Files.list(directory) // filter out files that don't end in .war or .jar .filter((path) -> { String extension = com.google.common.io.Files.getFileExtension(path.toString()); return extension.equals("war") || extension.equals("jar"); }).collect(Collectors.toList()); if (validArtifacts.size() < 1) { throw new ArtifactNotFoundException(); } else if (validArtifacts.size() > 1) { throw new TooManyArtifactsException(validArtifacts); } else { return validArtifacts.get(0); } }