本文整理汇总了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;
}