Package java.nio.file

Examples of java.nio.file.Path.toFile()


  private void removeFileOnDisk(Path root, Index toDelete) {
    Path path = FileUtil.getPath(root, toDelete);
    if (path == null) {
      logger.error("Could not find the file to delete.");
    }
    File file = path.toFile();
    if (!file.exists()) {
      logger.error("File does not exist and cannot be deleted.");
    }

    try {
View Full Code Here


                log.error("Could not create temp-file {}: {}", tmp, iox.getMessage());
                throw iox;
            }
            log.trace("using temporary file: {}", tmp);
            // Save the config to the tmp file
            conf.save(tmp.toFile());

            log.trace("tmp saved, now replacing the original file: {}", configPath);
            // Replace the original with the tmp file
            try {
                try {
View Full Code Here

        // Check for a configFile
        final Path config = importFile.getParent().resolve(configurationService.getStringConfiguration(CONFIG_KEY_CONF_FILE, "config"));
        if (Files.isReadable(config)) {
            try {
                Properties prop = new Properties();
                final FileInputStream inStream = new FileInputStream(config.toFile());
                prop.load(inStream);
                inStream.close();
                return prop;
            } catch (IOException e) {
                log.warn("could not read dirConfigFile {}: {}", config, e.getMessage());
View Full Code Here

  @Test
  public void getFileUnsupported() throws Exception {
    Path path = mock(Path.class);
    given(path.normalize()).willReturn(path);
    given(path.toFile()).willThrow(new UnsupportedOperationException());
    PathResource resource = new PathResource(path);
    thrown.expect(FileNotFoundException.class);
    resource.getFile();
  }
View Full Code Here

                //System.out.format("%s: %s\n", watchEvent.kind().name(), child);
               
                if (watchEventKind == ENTRY_MODIFY) {
                   
                    // we are not interested in events from parent directories...
                    if (! child.toFile().isDirectory()) {
                       
                        if (!checkIfMatchesPattern(exludePatterns, child.toFile().getAbsolutePath())) {
                       
                            System.out.println(
                                    "Found file modification - triggering reload:  "
View Full Code Here

                if (watchEventKind == ENTRY_MODIFY) {
                   
                    // we are not interested in events from parent directories...
                    if (! child.toFile().isDirectory()) {
                       
                        if (!checkIfMatchesPattern(exludePatterns, child.toFile().getAbsolutePath())) {
                       
                            System.out.println(
                                    "Found file modification - triggering reload:  "
                                        + child.toFile().getAbsolutePath());
                           
View Full Code Here

                       
                        if (!checkIfMatchesPattern(exludePatterns, child.toFile().getAbsolutePath())) {
                       
                            System.out.println(
                                    "Found file modification - triggering reload:  "
                                        + child.toFile().getAbsolutePath());
                           
                            restartAfterSomeTimeAndChanges.triggerRestart();
                           
                        }
                   
View Full Code Here

        exporter = new BundleExporter(cat,
            new ExportOpts(cat.getWorkspaceByName("foo")).name("blah"));

        exporter.run();
        Path zip = exporter.zip();
        ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(FileUtils.readFileToByteArray(zip.toFile())));
        ZipEntry entry = null;

        boolean foundBundle = false;
        boolean foundWorkspace = false;
View Full Code Here

     */
    public Path zip() throws IOException {
        Path zip = temp.resolve(options.name()+".zip");
        try (
            OutputStream out =
                new BufferedOutputStream(new FileOutputStream(zip.toFile()));
        ) {
            ZipOutputStream zout = new ZipOutputStream(out);
            try {
                IOUtils.zipDirectory(root().toFile(), zout, null);
            }
View Full Code Here

        assertEquals("application/zip", response.getContentType());
        assertEquals("attachment; filename=\"sf.zip\"", response.getHeader("Content-Disposition"));

        Path tmp = Files.createTempDirectory(Paths.get("target"), "export");
        org.geoserver.data.util.IOUtils.decompress(
            new ByteArrayInputStream(response.getContentAsByteArray()), tmp.toFile());

        assertTrue(tmp.resolve("bundle.json").toFile().exists());
    }

    @Test
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.