Java Code Examples for org.openide.filesystems.FileObject#readSymbolicLink()

The following examples show how to use org.openide.filesystems.FileObject#readSymbolicLink() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileObjSymlinkTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testReadSymbolicLinkRelative() throws IOException {
    if (!checkSymlinksSupported()) {
        return;
    }
    File dir = getWorkDir();
    File folder = new File(dir, "folder");
    File link = new File(dir, "link");
    folder.mkdir();
    Path lp = Files.createSymbolicLink(link.toPath(), Paths.get("folder"));
    assertNotNull(lp);
    FileObject linkFO = FileUtil.toFileObject(link);
    assertNotNull(linkFO);
    FileObject dataFO = linkFO.readSymbolicLink();
    assertNotSame(linkFO, dataFO);
    assertNotNull(dataFO);
    assertEquals("folder", dataFO.getNameExt());
}
 
Example 2
Source File: FileObjSymlinkTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testReadSymbolicLinkAbsolute() throws IOException {
    if (!checkSymlinksSupported()) {
        return;
    }
    File dir = getWorkDir();
    File data = new File(dir, "data.dat");
    File link = new File(dir, "link.lnk");
    data.createNewFile();
    Files.createSymbolicLink(link.toPath(), data.toPath());
    FileObject linkFO = FileUtil.toFileObject(link);
    FileObject dataFO = linkFO.readSymbolicLink();
    assertNotSame(linkFO, dataFO);
    assertNotNull(dataFO);
    assertEquals("data.dat", dataFO.getNameExt());
}