Package java.nio.file

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


    Path file = Paths.get(location);
    if (!file.isAbsolute())
      file = file.toAbsolutePath();
    if (Files.isReadable(file)) {
      try {
        url = file.normalize().toUri().toURL();
      } catch (MalformedURLException e) {
      }
    }
    return url;
  }
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

    assertTrue(rootPath.isAbsolute());
   
    for (ToolSourceError buildError : buildErrors) {
      Path path = buildError.getFilePath();
      path = rootPath.resolve(path); // Absolute paths will remain unchanged.
      path = path.normalize();
     
      IFile[] files = ResourceUtils.getWorkspaceRoot().findFilesForLocationURI(path.toUri());
      for (IFile file : files) {
        if(!file.exists())
          continue;
View Full Code Here

            if (lengthReceived == receivingModule.getSize()) {
                // finished
                downloadingModule.close();
                String moduleName = String.format("%s-%s.jar", receivingModule.getId(), receivingModule.getVersion());
                Path finalPath = PathManager.getInstance().getHomeModPath().normalize().resolve(moduleName);
                if (finalPath.normalize().startsWith(PathManager.getInstance().getHomeModPath())) {
                    if (Files.exists(finalPath)) {
                        logger.error("File already exists at {}", finalPath);
                        joinStatus.setErrorMessage("Module download error");
                        channelHandlerContext.getChannel().close();
                        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.