本文整理匯總了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"));
}
示例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;
}