本文整理汇总了Java中org.apache.commons.vfs2.FileName.getRelativeName方法的典型用法代码示例。如果您正苦于以下问题:Java FileName.getRelativeName方法的具体用法?Java FileName.getRelativeName怎么用?Java FileName.getRelativeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.vfs2.FileName
的用法示例。
在下文中一共展示了FileName.getRelativeName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFile
import org.apache.commons.vfs2.FileName; //导入方法依赖的package包/类
/**
* Creates a file object. This method is called only if the requested
* file is not cached.
*/
@Override
protected FileObject createFile(final AbstractFileName name) throws Exception
{
// Find the file that the name points to
final FileName junctionPoint = getJunctionForFile(name);
final FileObject file;
if (junctionPoint != null)
{
// Resolve the real file
final FileObject junctionFile = junctions.get(junctionPoint);
final String relName = junctionPoint.getRelativeName(name);
file = junctionFile.resolveFile(relName, NameScope.DESCENDENT_OR_SELF);
}
else
{
file = null;
}
// Return a wrapper around the file
return new DelegateFileObject(name, this, file);
}
示例2: testRelName
import org.apache.commons.vfs2.FileName; //导入方法依赖的package包/类
/**
* Checks that a file name converts to an expected relative path
*/
private void testRelName(final FileName baseName,
final String relPath)
throws Exception
{
final FileName expectedName = getManager().resolveName(baseName, relPath);
// Convert to relative path, and check
final String actualRelPath = baseName.getRelativeName(expectedName);
assertEquals(relPath, actualRelPath);
}
示例3: pathFromRoot
import org.apache.commons.vfs2.FileName; //导入方法依赖的package包/类
/**
* @param file the file
* @return the full path
*/
public final String pathFromRoot(FileObject file) {
FileName rootFolderName = rootFolder.getName();
FileName fileName = file.getName();
try {
return rootFolderName.getRelativeName(fileName);
} catch (FileSystemException e) {
throw new AutomationException("Error resolving relative path " +
rootFolderName.getPath() + " -> " + fileName.getPath(), e);
}
}