当前位置: 首页>>代码示例>>Java>>正文


Java FileSystem类代码示例

本文整理汇总了Java中org.apache.commons.vfs2.FileSystem的典型用法代码示例。如果您正苦于以下问题:Java FileSystem类的具体用法?Java FileSystem怎么用?Java FileSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileSystem类属于org.apache.commons.vfs2包,在下文中一共展示了FileSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: destroy

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
@Override
public void destroy() {
  LOG.info(Utils.format("Destroying {}", getInfo().getInstanceName()));
  try {
    IOUtils.closeQuietly(currentStream);
    IOUtils.closeQuietly(parser);
    if (remoteDir != null) {
      remoteDir.close();
      FileSystem fs = remoteDir.getFileSystem();
      remoteDir.getFileSystem().getFileSystemManager().closeFileSystem(fs);
    }
  } catch (IOException ex) {
    LOG.warn("Error during destroy", ex);
  } finally {
    remoteDir = null;
    //This forces the use of same RemoteDownloadSource object
    //not to have dangling reference to old stream (which is closed)
    //Also forces to initialize the next in produce call.
    currentStream = null;
    parser = null;
    currentOffset = null;
    next = null;
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:25,代码来源:RemoteDownloadSource.java

示例2: getFile

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
public FileObject getFile(final FileSystem filesystem, final FileName name)
{
    Map<FileName, Reference<FileObject>> files = getOrCreateFilesystemCache(filesystem);

    lock.lock();
    try
    {
        Reference<FileObject> ref = files.get(name);
        if (ref == null)
        {
            return null;
        }

        FileObject fo = ref.get();
        if (fo == null)
        {
            removeFile(filesystem, name);
        }
        return fo;
    }
    finally
    {
        lock.unlock();
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:26,代码来源:SoftRefFilesCache.java

示例3: filesystemClose

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
/**
 * Called while the lock is held
 * @param filesystem The file system to close.
 */
private void filesystemClose(FileSystem filesystem)
{
    if (log.isDebugEnabled())
    {
        log.debug("close fs: " + filesystem.getRootName());
    }

    filesystemCache.remove(filesystem);
    if (filesystemCache.size() < 1)
    {
        endThread();
    }
    /* This is not thread-safe as another thread might be opening the file system
    ((DefaultFileSystemManager) getContext().getFileSystemManager())
            ._closeFileSystem(filesystem);
     */
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:22,代码来源:SoftRefFilesCache.java

示例4: getOrCreateFilesystemCache

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
protected Map<FileName, Reference<FileObject>> getOrCreateFilesystemCache(final FileSystem filesystem)
{
    if (filesystemCache.size() < 1)
    {
        startThread();
    }

    Map<FileName, Reference<FileObject>> files;

    do
    {
        files = filesystemCache.get(filesystem);
        if (files != null)
        {
            break;
        }
        files = new HashMap<FileName, Reference<FileObject>>();
    } while (filesystemCache.putIfAbsent(filesystem, files) == null);

    return files;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:22,代码来源:SoftRefFilesCache.java

示例5: getFile

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
public FileObject getFile(final FileSystem filesystem, final FileName name)
{
    Map<FileName, FileObject> files = getOrCreateFilesystemCache(filesystem);

    readLock.lock();
    try
    {
        // FileObject fo = (FileObject) files.get(name);
        // System.err.println(">>> " + files.size() + " get:" + name.toString() + " " + fo);

        return files.get(name);
    }
    finally
    {
        readLock.unlock();
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:18,代码来源:LRUFilesCache.java

示例6: clear

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
public void clear(final FileSystem filesystem)
{
    Map<FileName, FileObject> files = getOrCreateFilesystemCache(filesystem);

    writeLock.lock();
    try
    {
        // System.err.println(">>> clear fs " + filesystem);

        files.clear();

        filesystemCache.remove(filesystem);
    }
    finally
    {
        writeLock.unlock();
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:19,代码来源:LRUFilesCache.java

示例7: removeFile

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
public void removeFile(final FileSystem filesystem, final FileName name)
{
    Map<?, ?> files = getOrCreateFilesystemCache(filesystem);

    writeLock.lock();
    try
    {
        // System.err.println(">>> " + files.size() + " remove:" + name.toString());

        files.remove(name);

        if (files.size() < 1)
        {
            filesystemCache.remove(filesystem);
        }
    }
    finally
    {
        writeLock.unlock();
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:22,代码来源:LRUFilesCache.java

示例8: createFileSystem

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
/**
 * Creates a layered file system.
 * @param scheme The protocol to use.
 * @param file a FileObject.
 * @param fileSystemOptions Options to access the FileSystem.
 * @return A FileObject associated with the new FileSystem.
 * @throws FileSystemException if an error occurs.
 */
@Override
public synchronized FileObject createFileSystem(final String scheme,
                                                final FileObject file,
                                                final FileSystemOptions fileSystemOptions)
    throws FileSystemException
{
    // Check if cached
    final FileName rootName = file.getName();
    FileSystem fs = findFileSystem(rootName, null);
    if (fs == null)
    {
        // Create the file system
        fs = doCreateFileSystem(scheme, file, fileSystemOptions);
        addFileSystem(rootName, fs);
    }
    return fs.getRoot();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:26,代码来源:AbstractLayeredFileProvider.java

示例9: closeFileSystem

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
/**
 * Close the FileSystem.
 * @param filesystem The FileSystem to close.
 */
public void closeFileSystem(final FileSystem filesystem)
{
    AbstractFileSystem fs = (AbstractFileSystem) filesystem;

    synchronized (this)
    {
        if (fs.getCacheKey() != null)
        {
            fileSystems.remove(fs.getCacheKey());
        }
    }

    removeComponent(fs);
    fs.close();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:20,代码来源:AbstractFileProvider.java

示例10: 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());
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:28,代码来源:JunctionTests.java

示例11: getHDFSFileSystem

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
@Override
public HadoopFileSystem getHDFSFileSystem() throws FileSystemException {
  if (fs == null) {
    Configuration conf = new Configuration();
    conf.set("fs.maprfs.impl", MapRFileProvider.FS_MAPR_IMPL);

    GenericFileName rootName = (GenericFileName) getRootName();
    String url = rootName.getScheme() + "://" + rootName.getHostName().trim();
    if (rootName.getPort() != MapRFileNameParser.DEFAULT_PORT) {
      url += ":" + rootName.getPort();
    }
    url += "/";
    conf.set("fs.default.name", url);
    setFileSystemOptions( getFileSystemOptions(), conf );
    try {
      fs = new HadoopFileSystemImpl( org.apache.hadoop.fs.FileSystem.get(conf) );
    } catch (Throwable t) {
      throw new FileSystemException("Could not get MapR FileSystem for " + url, t);
    }
  }
  return fs;
}
 
开发者ID:pentaho,项目名称:pentaho-hdfs-vfs,代码行数:23,代码来源:MapRFileSystem.java

示例12: accept

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
/**
 * Checks to see if the file can be written to.
 * 
 * @param fileInfo
 *            the File to check
 * 
 * @return {@code true} if the file can be written to, otherwise
 *         {@code false}.
 */
@Override
public boolean accept(final FileSelectInfo fileInfo) {
    try {
        final FileSystem fileSystem = fileInfo.getFile().getFileSystem();
        if (fileInfo.getFile().exists()) {
            if (!fileSystem.hasCapability(Capability.WRITE_CONTENT)) {
                return false;
            }
            return fileInfo.getFile().isWriteable();
        } else {
            if (!fileSystem.hasCapability(Capability.CREATE)) {
                return false;
            }
            return fileInfo.getFile().getParent().isWriteable();
        }
    } catch (final FileSystemException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:fuinorg,项目名称:commons-vfs2-filters,代码行数:29,代码来源:CanWriteFileFilter.java

示例13: close

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
protected void close() {
	FileSystem fs = null;
	if(this.root != null) {
		fs = this.root.getFileSystem();
		this.fsManager.closeFileSystem(fs);
		this.root = null;
	}
}
 
开发者ID:EsupPortail,项目名称:esup-sgc,代码行数:9,代码来源:VfsAccessService.java

示例14: doCreateFileSystem

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
/**
 * Creates the filesystem.
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
    throws FileSystemException
{
    return new NfsFileSystem(name, fileSystemOptions);
}
 
开发者ID:danniss,项目名称:common-vfs2-nfs,代码行数:10,代码来源:NfsFileProvider.java

示例15: getBaseFileSystem

import org.apache.commons.vfs2.FileSystem; //导入依赖的package包/类
public static FileSystem getBaseFileSystem() {
    try {
        return getFileSystemManager().getBaseFile().getFileSystem();
    } catch (final FileSystemException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:8,代码来源:VFSUtils.java


注:本文中的org.apache.commons.vfs2.FileSystem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。