當前位置: 首頁>>代碼示例>>Java>>正文


Java FileObject.getCanonicalFileObject方法代碼示例

本文整理匯總了Java中org.openide.filesystems.FileObject.getCanonicalFileObject方法的典型用法代碼示例。如果您正苦於以下問題:Java FileObject.getCanonicalFileObject方法的具體用法?Java FileObject.getCanonicalFileObject怎麽用?Java FileObject.getCanonicalFileObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.filesystems.FileObject的用法示例。


在下文中一共展示了FileObject.getCanonicalFileObject方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testGetRealFileObject

import org.openide.filesystems.FileObject; //導入方法依賴的package包/類
/**
 * Test getCanonicalFileObject method.
 *
 * Use this directory tree:
 * <pre>
 * - workdir
 *   - a
 *     - data.dat
 *   - b
 *     - link.lnk (symlink to data.dat)
 *   - c
 *     - link2.lnk (symlink to link.link)
 *   - d
 *     - folderLink (symlink to c)
 * </pre>
 * @throws java.io.IOException
 */
public void testGetRealFileObject() throws IOException {
    if (!checkSymlinksSupported()) {
        return;
    }
    File dir = getWorkDir();
    File a = new File(dir, "a");
    File dataDat = new File(a, "data.dat");
    File b = new File(dir, "b");
    File linkLnk = new File(b, "link.lnk");
    File c = new File(dir, "c");
    File link2Lnk = new File(c, "link2.lnk");
    File d = new File(dir, "d");
    File folderLink = new File(d, "folderLink");
    a.mkdir();
    dataDat.createNewFile();
    b.mkdir();
    Files.createSymbolicLink(linkLnk.toPath(), dataDat.toPath());
    c.mkdir();
    Files.createSymbolicLink(link2Lnk.toPath(), linkLnk.toPath());
    d.mkdir();
    Files.createSymbolicLink(folderLink.toPath(), c.toPath());
    FileObject dirFO = FileUtil.toFileObject(dir);
    dirFO.refresh();
    FileObject fo = dirFO.getFileObject("d/folderLink/link2.lnk");
    assertNotNull(fo);
    FileObject realFO = fo.getCanonicalFileObject();
    assertNotNull(realFO);
    assertTrue(realFO.getPath().endsWith("a/data.dat"));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:47,代碼來源:FileObjSymlinkTest.java

示例2: isSameFile

import org.openide.filesystems.FileObject; //導入方法依賴的package包/類
private static boolean isSameFile(
        @NonNull final FileObject check,
        @NonNull final FileObject other) throws IOException {
    if (check.isSymbolicLink()) {
        FileObject otherReslved = other.getCanonicalFileObject();
        if (otherReslved == null) {
            otherReslved = other;
        }
        return otherReslved.equals(check.getCanonicalFileObject());
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:FileObjectCrawler.java


注:本文中的org.openide.filesystems.FileObject.getCanonicalFileObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。