List of usage examples for java.nio.file Path toFile
default File toFile()
From source file:io.github.swagger2markup.extensions.DynamicDocumentExtensionTest.java
@Test public void testSwagger2AsciiDocExtensions() throws IOException, URISyntaxException { //Given//from w w w . jav a2 s. co m Path file = Paths .get(DynamicDocumentExtensionTest.class.getResource("/yaml/swagger_petstore.yaml").toURI()); Path outputDirectory = Paths.get("build/test/asciidoc/generated"); FileUtils.deleteQuietly(outputDirectory.toFile()); //When Properties properties = new Properties(); properties .load(DynamicDocumentExtensionTest.class.getResourceAsStream("/config/asciidoc/config.properties")); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder(properties).build(); Swagger2MarkupExtensionRegistry registry = new Swagger2MarkupExtensionRegistryBuilder() //.withDefinitionsDocumentExtension(new DynamicDefinitionsDocumentExtension(Paths.get("src/test/resources/docs/asciidoc/extensions"))) //.withPathsDocumentExtension(new DynamicPathsDocumentExtension(Paths.get("src/test/resources/docs/asciidoc/extensions"))) .build(); Swagger2MarkupConverter.from(file).withConfig(config).withExtensionRegistry(registry).build() .toFolder(outputDirectory); //Then assertThat(new String(Files.readAllBytes(outputDirectory.resolve("paths.adoc")))) .contains("Pet update request extension"); assertThat(new String(Files.readAllBytes(outputDirectory.resolve("definitions.adoc")))) .contains("Pet extension"); }
From source file:edu.chalmers.dat076.moviefinder.service.FileThreadServiceImpl.java
@Override public void addListeningPath(Path p) { try {/*from w ww . jav a 2 s .c o m*/ threads.add(new WatchThread(p.toFile())); threads.getLast().setListener(this); threads.getLast().start(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, null, ex); } }
From source file:ch.admin.suis.msghandler.config.SigningOutbox.java
/** * Returns all PDF files which are in the "signingOutboxDir" directory. These PDFs will be signed later. After a * successful sign process these files should be moved to: * <code>getProcessedDir()</code>. If * <code>getProcessedDir()</code> is null these files should be deleted. * * @return The PDFs that need to be signed */// www.j av a 2 s . c om public List<File> getAllPDFsToSign() { try (DirectoryStream<Path> files = FileUtils.listFiles(signingOutboxDir, FileFilters.PDF_FILTER_PATH)) { List<File> retVal = new ArrayList<>(); for (Path path : files) { retVal.add(path.toFile()); } files.close(); return retVal; } catch (IOException e) { throw new UnhandledException(e); } }
From source file:io.github.swagger2markup.extensions.DynamicDocumentExtensionTest.java
@Test public void testSwagger2MarkdownExtensions() throws IOException, URISyntaxException { //Given// www . j av a 2s . c o m Path file = Paths .get(DynamicDocumentExtensionTest.class.getResource("/yaml/swagger_petstore.yaml").toURI()); Path outputDirectory = Paths.get("build/test/markdown/generated"); FileUtils.deleteQuietly(outputDirectory.toFile()); //When Properties properties = new Properties(); properties .load(DynamicDocumentExtensionTest.class.getResourceAsStream("/config/markdown/config.properties")); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder(properties) .withMarkupLanguage(MarkupLanguage.MARKDOWN).build(); Swagger2MarkupExtensionRegistry registry = new Swagger2MarkupExtensionRegistryBuilder() //.withDefinitionsDocumentExtension(new DynamicDefinitionsDocumentExtension(Paths.get("src/test/resources/docs/markdown/extensions"))) //.withPathsDocumentExtension(new DynamicPathsDocumentExtension(Paths.get("src/test/resources/docs/markdown/extensions"))) .build(); Swagger2MarkupConverter.from(file).withConfig(config).withExtensionRegistry(registry).build() .toFolder(outputDirectory); //Then assertThat(new String(Files.readAllBytes(outputDirectory.resolve("paths.md")))) .contains("Pet update request extension"); assertThat(new String(Files.readAllBytes(outputDirectory.resolve("definitions.md")))) .contains("Pet extension"); }
From source file:com.github.cbismuth.fdupes.io.PathOrganizer.java
private void onTimestampPath(final PathElement pathElement, final Path timestampPath) { try {//ww w . ja v a 2s. c o m FileUtils.moveFile(pathElement.getPath().toFile(), timestampPath.toFile()); } catch (final IOException e) { LOGGER.error(e.getMessage()); } }
From source file:gumga.framework.application.service.GumgaFreemarkerTemplateEngineService.java
@Override public void init() throws TemplateEngineException { if (cfg == null) { try {// www . j a v a2s .com //Creates the template folder if it doesn't exists... checkFolder(this.templateFolder); //...then copies default templates in there URL resourceUrl = getClass().getResource("/templates"); Path resourcePath = Paths.get(resourceUrl.toURI()); for (File file : resourcePath.toFile().listFiles()) { File destination = new File(this.templateFolder + File.separator + file.getName()); if (!destination.exists()) { Files.copy(file, destination); } } initStatic(); cfg.setDirectoryForTemplateLoading(new File(this.templateFolder)); cfg.setDefaultEncoding(this.defaultEncoding); cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); } catch (IOException ex) { throw new TemplateEngineException("An error occurred while initializating the template engine", ex); } catch (URISyntaxException e) { throw new TemplateEngineException("An error occurred while initializating the template engine", e); } catch (java.nio.file.FileSystemNotFoundException ex) { System.out.println("------->Templates no encontrados." + ex); } } }
From source file:ch.sourcepond.maven.plugin.jenkins.it.CreateJobITCase.java
/** * @throws Exception/*from w w w .ja v a 2 s . com*/ */ @Override @Test public void verifyHttpRequest() throws Exception { mojo.execute(); final Path stdout = TARGET.resolve(UUID.randomUUID().toString()); mojo.setStdout(stdout.toFile()); mojo.setStdin(null); mojo.setStdinXsltFile(null); mojo.setStdoutXsltParams(null); mojo.setCommand("get-job " + JOB_NAME); mojo.execute(); final Document job = documentBuilderFactory.newDocumentBuilder().parse(stdout.toFile()); assertEquals(DESCRIPTION_VALUE, xpath.evaluate("/maven2-moduleset/description/text()", job)); assertEquals(GITURL_VALUE, xpath.evaluate( "/maven2-moduleset/scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/url/text()", job)); assertEquals(CREDENTIALS_ID_VALUE, xpath.evaluate( "/maven2-moduleset/scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/credentialsId/text()", job)); assertEquals(GROUP_ID_VALUE, xpath.evaluate("/maven2-moduleset/rootModule/groupId/text()", job)); assertEquals(ARTIFACT_ID_VALUE, xpath.evaluate("/maven2-moduleset/rootModule/artifactId/text()", job)); }
From source file:gr.upatras.ece.nam.baker.impl.RepositoryWebClient.java
@Override public Path fetchPackageFromLocation(String uuid, String packageLocation) { logger.info("fetchPackageFromLocation: " + packageLocation); try {/*from w ww . j a v a2s. c o m*/ WebClient client = WebClient.create(packageLocation); Response r = client.get(); InputStream inputStream = (InputStream) r.getEntity(); //Path tempDir = Files.createTempDirectory("baker"); String tempDir = System.getProperty("user.home") + File.separator + ".baker" + File.separator + "extractedbuns"; File destFile = new File(tempDir + File.separator + uuid + File.separator + "bun.tar.gz"); Files.createDirectories(Paths.get(tempDir + File.separator + uuid)); Path targetPath = destFile.toPath(); OutputStream output = new FileOutputStream(targetPath.toFile()); IOUtils.copy(inputStream, output); return targetPath; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:it.sonarlint.cli.tools.SonarlintInstaller.java
private void installZip(Path zipFilePath, Path toDir) { try {/*w ww . j av a 2s . c o m*/ ZipFile zipFile = new ZipFile(zipFilePath.toFile()); zipFile.extractAll(toDir.toString()); } catch (Exception e) { throw new IllegalStateException("Fail to unzip sonarlint cli to" + toDir, e); } }
From source file:its.tools.SonarlintInstaller.java
private void installZip(Path zipFilePath, Path toDir) { try {/* www . j a va 2s . co m*/ ZipFile zipFile = new ZipFile(zipFilePath.toFile()); zipFile.extractAll(toDir.toString()); } catch (Exception e) { throw new IllegalStateException("Fail to unzip SonarLint Daemon to" + toDir, e); } }