Package java.nio.file

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


  public void moveIfExists() throws IOException {
    final Path target = util.createTempDir().toPath();
    assertThat(DirSupport.moveIfExists(root.toPath().resolve("not-existing"), target), is(false));
    assertThat(DirSupport.moveIfExists(root.toPath(), target), is(true));
    assertThat(root, not(exists()));
    assertThat(target.toFile(), exists());
    assertThat(target.toFile(), isDirectory());
    assertThat(target.toFile(), not(isEmptyDirectory()));
    assertThat(target.resolve("dir2").resolve("dir21").toFile(), isDirectory());
    assertThat(target.resolve("dir2").resolve("dir21").resolve("file211.txt").toFile(), isFile());
  }
View Full Code Here


    final Path target = util.createTempDir().toPath();
    assertThat(DirSupport.moveIfExists(root.toPath().resolve("not-existing"), target), is(false));
    assertThat(DirSupport.moveIfExists(root.toPath(), target), is(true));
    assertThat(root, not(exists()));
    assertThat(target.toFile(), exists());
    assertThat(target.toFile(), isDirectory());
    assertThat(target.toFile(), not(isEmptyDirectory()));
    assertThat(target.resolve("dir2").resolve("dir21").toFile(), isDirectory());
    assertThat(target.resolve("dir2").resolve("dir21").resolve("file211.txt").toFile(), isFile());
  }
View Full Code Here

    assertThat(DirSupport.moveIfExists(root.toPath().resolve("not-existing"), target), is(false));
    assertThat(DirSupport.moveIfExists(root.toPath(), target), is(true));
    assertThat(root, not(exists()));
    assertThat(target.toFile(), exists());
    assertThat(target.toFile(), isDirectory());
    assertThat(target.toFile(), not(isEmptyDirectory()));
    assertThat(target.resolve("dir2").resolve("dir21").toFile(), isDirectory());
    assertThat(target.resolve("dir2").resolve("dir21").resolve("file211.txt").toFile(), isFile());
  }

  @Test
View Full Code Here

    final Path root = appDirs.getWorkDirectory("rawBinaries").toPath();

    Path content = root.resolve("content");
    Path metadata = root.resolve("metadata");

    this.metadataStore = MapdbBlobMetadataStore.create(metadata.toFile());

    final FileBlobStore fileBlobStore = new FileBlobStore(content, new VolumeChapterLocationStrategy(),
        new SimpleFileOperations(), metadataStore);

    return fileBlobStore;
View Full Code Here

    protected static HttpApplicationFactory httpApplicationFactory;

    protected void loadConfiguration() {
        Path propertiesFilePath = Paths.get(SystemProperties.getUserHomeDirectory(), ".com.ramforth.webserver", "webserver.config");

        File propertiesFile = propertiesFilePath.toFile();

        if (propertiesFile.exists()) {
            try (InputStream is = new BufferedInputStream(new FileInputStream(propertiesFile))) {
                configurationProperties.load(is);
            } catch (IOException ioex) {
View Full Code Here

    @Test
    public void toPath() {
        final String pathStrInput = tempDir.getRoot().getAbsolutePath();
        final Path path = IOUtil.toPath(pathStrInput);
        final String absPathOutput = path.toFile().getAbsolutePath();
        assertEquals(pathStrInput, absPathOutput);
    }

    @Test
    public void toPathWithInvalidPath() {
View Full Code Here

    @Test
    public void toPathWithNonExistingFile() {
        final String pathStrInput = new File(NON_EXISTANT_FILE)
        .getAbsolutePath();
        final Path path = IOUtil.toPath(NON_EXISTANT_FILE);
        final String absPathOutput = path.toFile().getAbsolutePath();
        assertEquals(pathStrInput, absPathOutput);
    }

    /**
     * @return A root directory of the file system. Should work system
View Full Code Here

    return new Callable<Path>() {

      @Override
      public Path call() throws Exception {
        final Path chunkPath = (chunk == 0) ? downloadTo : Paths.get(downloadTo + "_" + chunk);
        chunkPath.toFile().deleteOnExit();

        final long startTime = System.currentTimeMillis();

        final long byteRangeStart = chunk * chunkSize;
        final long byteRangeEnd = Math.min((chunk + 1) * chunkSize - 1, length);
View Full Code Here

      return;
    }

    // check if file is on disk
    Path path = FileUtil.getPath(session.getRoot(), index);
    if (path == null || !path.toFile().exists()) {
      logger.info("File not found on disk, cannot return a chunk");
      sendDirectResponse(createResponse(null));
      return;
    }
View Full Code Here

    }

    Chunk chunk = null;
    try {
      // retrieve the requested file part (offset and length)
      chunk = FileChunkUtil.getChunk(path.toFile(), chunkLength, chunkNumber, "chunk-" + chunkNumber);
    } catch (IOException e) {
      logger.error("Cannot read the chunk", e);
      sendDirectResponse(createResponse(null));
      return;
    }
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.