本文整理汇总了Java中org.apache.commons.vfs2.FileSystem.resolveFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystem.resolveFile方法的具体用法?Java FileSystem.resolveFile怎么用?Java FileSystem.resolveFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.vfs2.FileSystem
的用法示例。
在下文中一共展示了FileSystem.resolveFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAncestors
import org.apache.commons.vfs2.FileSystem; //导入方法依赖的package包/类
/**
* Checks ancestors are created when a junction is created.
*/
public void testAncestors() throws Exception
{
final FileSystem fs = getManager().createVirtualFileSystem("vfs://").getFileSystem();
final FileObject baseDir = getBaseDir();
// Make sure the file at the junction point and its ancestors do not exist
FileObject file = fs.resolveFile("/a/b");
assertFalse(file.exists());
file = file.getParent();
assertFalse(file.exists());
file = file.getParent();
assertFalse(file.exists());
// Add the junction
fs.addJunction("/a/b", baseDir);
// Make sure the file at the junction point and its ancestors exist
file = fs.resolveFile("/a/b");
assertTrue("Does not exist", file.exists());
file = file.getParent();
assertTrue("Does not exist", file.exists());
file = file.getParent();
assertTrue("Does not exist", file.exists());
}
示例2: findFile
import org.apache.commons.vfs2.FileSystem; //导入方法依赖的package包/类
/**
* Locates a file object, by absolute URI.
* @param baseFile The base FileObject.
* @param uri The URI of the file to be located.
* @param properties FileSystemOptions to use to locate or create the file.
* @return The FileObject.
* @throws FileSystemException if an error occurs.
*/
public synchronized FileObject findFile(final FileObject baseFile, final String uri,
final FileSystemOptions properties)
throws FileSystemException
{
// Parse the name
final StringBuilder buffer = new StringBuilder(uri);
final String scheme = UriParser.extractScheme(uri, buffer);
UriParser.fixSeparators(buffer);
FileType fileType = UriParser.normalisePath(buffer);
final String path = buffer.toString();
// Create the temp file system if it does not exist
// FileSystem filesystem = findFileSystem( this, (Properties) null);
FileSystem filesystem = findFileSystem(this, properties);
if (filesystem == null)
{
if (rootFile == null)
{
rootFile = getContext().getTemporaryFileStore().allocateFile("tempfs");
}
final FileName rootName =
getContext().parseURI(scheme + ":" + FileName.ROOT_PATH);
// final FileName rootName =
// new LocalFileName(scheme, scheme + ":", FileName.ROOT_PATH);
filesystem = new LocalFileSystem(rootName, rootFile.getAbsolutePath(), properties);
addFileSystem(this, filesystem);
}
// Find the file
return filesystem.resolveFile(path);
}
示例3: findFile
import org.apache.commons.vfs2.FileSystem; //导入方法依赖的package包/类
/**
* Locates a file from its parsed URI. Can be used to set default timeout for ftp and ftps
* connections.
*
* @param name The file name.
* @param fileSystemOptions FileSystem options.
* @param timeout timeout when connecting with ftp or ftps
* @return A FileObject associated with the file.
* @throws FileSystemException if an error occurs.
*/
protected FileObject findFile(final FileName name, final FileSystemOptions fileSystemOptions, Integer timeout)
throws FileSystemException {
// Check in the cache for the file system
final FileName rootName =
getContext().getFileSystemManager().resolveName(name, FileName.ROOT_PATH);
FileSystem fs = getFileSystem(rootName, fileSystemOptions,timeout);
// Locate the file
// return fs.resolveFile(name.getPath());
return fs.resolveFile(name);
}
示例4: findFile
import org.apache.commons.vfs2.FileSystem; //导入方法依赖的package包/类
/**
* Locates a file object, by absolute URI.
* @param baseFile The base FileObject.
* @param uri The uri of the file to locate.
* @param fileSystemOptions The FileSystemOptions
* @return The FileObject
* @throws FileSystemException if an error occurs.
*/
public synchronized FileObject findFile(final FileObject baseFile,
final String uri,
final FileSystemOptions fileSystemOptions)
throws FileSystemException
{
try
{
final URL url = new URL(uri);
URL rootUrl = new URL(url, "/");
final String key = this.getClass().getName() + rootUrl.toString();
FileSystem fs = findFileSystem(key, fileSystemOptions);
if (fs == null)
{
String extForm = rootUrl.toExternalForm();
final FileName rootName =
getContext().parseURI(extForm);
// final FileName rootName =
// new BasicFileName(rootUrl, FileName.ROOT_PATH);
fs = new UrlFileSystem(rootName, fileSystemOptions);
addFileSystem(key, fs);
}
return fs.resolveFile(url.getPath());
}
catch (final MalformedURLException e)
{
throw new FileSystemException("vfs.provider.url/badly-formed-uri.error", uri, e);
}
}
示例5: getBaseTestFolder
import org.apache.commons.vfs2.FileSystem; //导入方法依赖的package包/类
/**
* Returns the base folder for tests.
*/
public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
{
final FileObject baseFolder = config.getBaseTestFolder(manager);
// Create an empty file system, then link in the base folder
final FileSystem newFs = manager.createVirtualFileSystem("vfs:").getFileSystem();
final String junctionPoint = "/some/dir";
newFs.addJunction(junctionPoint, baseFolder);
return newFs.resolveFile(junctionPoint);
}