Package java.io

Examples of java.io.File.toPath()


    @Test
    public void testCreateSymlinks() throws IOException, URISyntaxException {
        File rootPath = new File(getClass().getResource("page.html").toURI()).getParentFile();

        File newDir = new File(rootPath, "newDir");
        Path newDirPath = newDir.toPath();
        Assert.assertFalse(Files.isSymbolicLink(newDirPath));

        File innerDir = new File(newDir, "innerDir");
        Path innerDirPath = innerDir.toPath();
        Assert.assertFalse(Files.isSymbolicLink(innerDirPath));
View Full Code Here


        File newDir = new File(rootPath, "newDir");
        Path newDirPath = newDir.toPath();
        Assert.assertFalse(Files.isSymbolicLink(newDirPath));

        File innerDir = new File(newDir, "innerDir");
        Path innerDirPath = innerDir.toPath();
        Assert.assertFalse(Files.isSymbolicLink(innerDirPath));

        File newSymlink = new File(rootPath, "newSymlink");
        Path newSymlinkPath = newSymlink.toPath();
        Assert.assertTrue(Files.isSymbolicLink(newSymlinkPath));
View Full Code Here

        File innerDir = new File(newDir, "innerDir");
        Path innerDirPath = innerDir.toPath();
        Assert.assertFalse(Files.isSymbolicLink(innerDirPath));

        File newSymlink = new File(rootPath, "newSymlink");
        Path newSymlinkPath = newSymlink.toPath();
        Assert.assertTrue(Files.isSymbolicLink(newSymlinkPath));

        File innerSymlink = new File(newSymlink, "innerSymlink");
        Path innerSymlinkPath = innerSymlink.toPath();
        Assert.assertTrue(Files.isSymbolicLink(innerSymlinkPath));
View Full Code Here

        File newSymlink = new File(rootPath, "newSymlink");
        Path newSymlinkPath = newSymlink.toPath();
        Assert.assertTrue(Files.isSymbolicLink(newSymlinkPath));

        File innerSymlink = new File(newSymlink, "innerSymlink");
        Path innerSymlinkPath = innerSymlink.toPath();
        Assert.assertTrue(Files.isSymbolicLink(innerSymlinkPath));

        File f = innerSymlinkPath.getRoot().toFile();
        for (int i=0; i<innerSymlinkPath.getNameCount(); i++) {
            f = new File(f, innerSymlinkPath.getName(i).toString());
View Full Code Here

        Assert.assertTrue(Files.isSymbolicLink(innerSymlinkPath));

        File f = innerSymlinkPath.getRoot().toFile();
        for (int i=0; i<innerSymlinkPath.getNameCount(); i++) {
            f = new File(f, innerSymlinkPath.getName(i).toString());
            System.out.println(f + " " + Files.isSymbolicLink(f.toPath()));
        }
        f = new File(f, ".");
        System.out.println(f + " " + Files.isSymbolicLink(f.toPath()));
    }
View Full Code Here

        for (int i=0; i<innerSymlinkPath.getNameCount(); i++) {
            f = new File(f, innerSymlinkPath.getName(i).toString());
            System.out.println(f + " " + Files.isSymbolicLink(f.toPath()));
        }
        f = new File(f, ".");
        System.out.println(f + " " + Files.isSymbolicLink(f.toPath()));
    }

    @Test
    public void testDefaultAccessSymlinkDenied() throws IOException, URISyntaxException {
        TestHttpClient client = new TestHttpClient();
View Full Code Here

     */
    private boolean isSymlinkPath(final String base, final File file) throws IOException {
        Path path = file.toPath();
        int nameCount = path.getNameCount();
        File root = new File(base);
        Path rootPath = root.toPath();
        int rootCount = rootPath.getNameCount();
        if (nameCount > rootCount) {
            File f = root;
            for (int i= rootCount; i<nameCount; i++) {
                f = new File(f, path.getName(i).toString());
View Full Code Here

        int rootCount = rootPath.getNameCount();
        if (nameCount > rootCount) {
            File f = root;
            for (int i= rootCount; i<nameCount; i++) {
                f = new File(f, path.getName(i).toString());
                if (Files.isSymbolicLink(f.toPath())) {
                    return true;
                }
            }
        }
        return false;
View Full Code Here

    // System.out.println(currentPath);

    final File folder = new File(currentPath);

    if (!Files.exists(folder.toPath(), LinkOption.NOFOLLOW_LINKS)) {

      LOGGER.log(Level.WARNING, "skip '" + currentPath + "'. does not exists anymore.");
      return new File[] {};
    }
View Full Code Here

    File file = new File(localPath + Item.SEPARATOR + item.getPath());

    try {
      if (item.isType(ItemType.LINK)) {

        byte[] data = Files.readSymbolicLink(file.toPath()).toString().getBytes();
        item.setChecksum(createChecksum(data));
        return data;
      } else if (item.isType(ItemType.FILE)) {

        byte[] data = Files.readAllBytes(file.toPath());
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.