• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FileName类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parseUri

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Parses URI and constructs S3 file name.
 */
public FileName parseUri(final VfsComponentContext context, final FileName base, final String filename) throws FileSystemException {
	StringBuffer name = new StringBuffer();

	String scheme = UriParser.extractScheme(filename, name);
	UriParser.canonicalizePath(name, 0, name.length(), this);

	// Normalize separators in the path
	UriParser.fixSeparators(name);

	// Normalise the path
	FileType fileType = UriParser.normalisePath(name);

	// Extract bucket name
	final String bucketName = UriParser.extractFirstElement(name);

	return new S3FileName(scheme, bucketName, name.toString(), fileType);
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:21,代码来源:S3FileNameParser.java


示例2: getFilename

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
public static String getFilename(FileObject fileObject)
{
    FileName fileName = fileObject.getName();
    String root = fileName.getRootURI();
    if (!root.startsWith("file:")) return fileName.getURI(); // nothing we can do about non-normal files.
    if (root.endsWith(":/")) // Windows
    {
        root = root.substring(8,10);
    }
    else // *nix & OSX
    {
        root = "";
    }
    String fileString = root + fileName.getPath();
    if (!"/".equals(Const.FILE_SEPARATOR))
    {
        fileString = Const.replace(fileString, "/", Const.FILE_SEPARATOR);
    }
    return fileString;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:21,代码来源:KettleVFS.java


示例3: setInternalFilenameKettleVariables

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
private void setInternalFilenameKettleVariables(VariableSpace var) {
  if (filename != null) // we have a filename that's defined.
  {
    try {
      FileObject fileObject = KettleVFS.getFileObject(filename, var);
      FileName fileName = fileObject.getName();

      // The filename of the job
      var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName());

      // The directory of the job
      FileName fileDir = fileName.getParent();
      var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI());
    } catch (Exception e) {
      var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "");
      var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, "");
    }
  } else {
    var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); //$NON-NLS-1$
    var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); //$NON-NLS-1$
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:23,代码来源:JobMeta.java


示例4: getFilename

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
public static String getFilename(FileObject fileObject)
{
    FileName fileName = fileObject.getName();
    String root = fileName.getRootURI();
    if (!root.startsWith("file:")) return fileName.getURI(); // nothing we can do about non-normal files. //$NON-NLS-1$
    if (root.startsWith("file:////")) return fileName.getURI(); // we'll see 4 forward slashes for a windows/smb network share
    if (root.endsWith(":/")) // Windows //$NON-NLS-1$
    {
        root = root.substring(8,10);
    }
    else // *nix & OSX
    {
        root = ""; //$NON-NLS-1$
    }
    String fileString = root + fileName.getPath();
    if (!"/".equals(Const.FILE_SEPARATOR)) //$NON-NLS-1$
    {
        fileString = Const.replace(fileString, "/", Const.FILE_SEPARATOR); //$NON-NLS-1$
    }
    return fileString;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:22,代码来源:KettleVFS.java


示例5: testChildName

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Tests child file names.
 */
public void testChildName() throws Exception
{
    final FileName baseName = getReadFolder().getName();
    final String basePath = baseName.getPath();
    final FileName name = getManager().resolveName(baseName, "some-child", NameScope.CHILD);

    // Test path is absolute
    assertTrue("is absolute", basePath.startsWith("/"));

    // Test base name
    assertEquals("base name", "some-child", name.getBaseName());

    // Test absolute path
    assertEquals("absolute path", basePath + "/some-child", name.getPath());

    // Test parent path
    assertEquals("parent absolute path", basePath, name.getParent().getPath());

    // Try using a compound name to find a child
    assertBadName(name, "a/b", NameScope.CHILD);

    // Check other invalid names
    checkDescendentNames(name, NameScope.CHILD);
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:28,代码来源:NamingTests.java


示例6: notifyParent

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Notify the parent of a change to its children, when a child is created
 * or deleted.
 */
private void notifyParent(FileName childName, FileType newType) throws Exception
{
    if (parent == null)
    {
        FileName parentName = name.getParent();
        if (parentName != null)
        {
            // Locate the parent, if it is cached
            parent = fs.getFileFromCache(parentName);
        }
    }

    if (parent != null)
    {
        FileObjectUtils.getAbstractFileObject(parent).childrenChanged(childName, newType);
    }
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:22,代码来源:AbstractFileObject.java


示例7: removeFile

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

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

        files.remove(name);

        if (files.size() < 1)
        {
            filesystemCache.remove(filesystem);
        }
    }
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:17,代码来源:LRUFilesCache.java


示例8: createFile

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Creates a file object.  This method is called only if the requested
 * file is not cached.
 */
protected FileObject createFile(final FileName 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 = (FileObject) 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);
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:26,代码来源:VirtualFileSystem.java


示例9: testGetParentOnFilesystemRoot

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
@Test(expected = FileSystemException.class)
public void testGetParentOnFilesystemRoot() throws org.apache.commons.vfs.FileSystemException,
        FileSystemException, MalformedURLException {
    FileObject rootFileObject;
    if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
        rootFileObject = fileSystemManager.resolveFile(new File("c:\\").toURI().toURL().toString());
    } else {
        rootFileObject = fileSystemManager.resolveFile(new File("/").toURI().toURL().toString());
    }
    final FileName mountintPointFileName = rootFileObject.getName();
    final FileObject rootAdaptee = rootFileObject;
    ArrayList<String> fos = new ArrayList<String>();
    fos.add("file:///");
    final DataSpacesFileObject fo = new VFSFileObjectAdapter(rootAdaptee, spaceURI,
        mountintPointFileName, fos);
    fo.getParent();
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:18,代码来源:VFSFileObjectAdapterTest.java


示例10: findFile

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Locates a file object, by absolute URI.
 * @param baseFile The base FileObject.
 * @param uri The name of the file to locate.
 * @param properties The FileSystemOptions.
 * @return The FileObject if it is located, null otherwise.
 * @throws FileSystemException if an error occurs.
 */
public FileObject findFile(final FileObject baseFile,
                           final String uri,
                           final FileSystemOptions properties) throws FileSystemException
{
    // Split the URI up into its parts
    final LayeredFileName name = (LayeredFileName) parseUri(baseFile != null ? baseFile.getName() : null, uri);

    // Make the URI canonical

    // Resolve the outer file name
    final FileName fileName = name.getOuterName();
    final FileObject file = getContext().resolveFile(baseFile, fileName.getURI(), properties);

    // Create the file system
    final FileObject rootFile = createFileSystem(name.getScheme(), file, properties);

    // Resolve the file
    return rootFile.resolveFile(name.getPath());
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:28,代码来源:AbstractLayeredFileProvider.java


示例11: testCd

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * @throws Exception
 */
@Test
public void testCd() throws Exception {
    
	String path = "c:/windows";
	FileName foldername = EgovFileUtil.getFileObject(path).getName();
	
	EgovFileUtil.cd("");
	
	String uri = EgovFileUtil.pwd().getURI();
	log.debug("EgovFileUtil.pwd().getURI() : " + uri);
	log.debug("foldername.getURI() : " + foldername.getURI());
	
	assertFalse(foldername.getURI().equals(uri));

	/////////////////////////////////////////////////////////////////
	// c:\windows 로 이동
	EgovFileUtil.cd(path);

	uri = EgovFileUtil.pwd().getURI();
	log.debug("EgovFileUtil.pwd().getURI() : " + uri);
	log.debug("foldername.getURI() : " + foldername.getURI());
	assertEquals(foldername.getURI(), EgovFileUtil.pwd().getURI());
}
 
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:27,代码来源:FilehandlingServiceTest.java


示例12: getChild

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Returns a child of this file.
 * @param name The name of the child to locate.
 * @return The FileObject for the file or null if the child does not exist.
 * @throws FileSystemException if an error occurs.
 */
public FileObject getChild(final String name) throws FileSystemException
{
    // TODO - use a hashtable when there are a large number of children
    FileObject[] children = getChildren();
    for (int i = 0; i < children.length; i++)
    {
        // final FileObject child = children[i];
        final FileName child = children[i].getName();
        // TODO - use a comparator to compare names
        // if (child.getName().getBaseName().equals(name))
        if (child.getBaseName().equals(name))
        {
            return resolveFile(child);
        }
    }
    return null;
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:24,代码来源:AbstractFileObject.java


示例13: testDescendentName

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Tests descendent name resolution.
 */
public void testDescendentName()
    throws Exception
{
    final FileName baseName = getReadFolder().getName();

    // Test direct child
    String path = baseName.getPath() + "/some-child";
    assertSameName(path, baseName, "some-child", NameScope.DESCENDENT);

    // Test compound name
    path = path + "/grand-child";
    assertSameName(path, baseName, "some-child/grand-child", NameScope.DESCENDENT);

    // Test relative names
    assertSameName(path, baseName, "./some-child/grand-child", NameScope.DESCENDENT);
    assertSameName(path, baseName, "./nada/../some-child/grand-child", NameScope.DESCENDENT);
    assertSameName(path, baseName, "some-child/./grand-child", NameScope.DESCENDENT);

    // Test badly formed descendent names
    checkDescendentNames(baseName, NameScope.DESCENDENT);
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:25,代码来源:NamingTests.java


示例14: findFile

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Locates a file object, by absolute URI.
 *
 * @param baseFile The base file object.
 * @param uri The URI of the file to locate
 * @param fileSystemOptions The FileSystem options.
 * @return The located FileObject
 * @throws FileSystemException if an error occurs.
 */
public FileObject findFile(final FileObject baseFile,
                           final String uri,
                           final FileSystemOptions fileSystemOptions) throws FileSystemException
{
    // Parse the URI
    final FileName name;
    try
    {
        name = parseUri(baseFile != null ? baseFile.getName() : null, uri);
    }
    catch (FileSystemException exc)
    {
        throw new FileSystemException("vfs.provider/invalid-absolute-uri.error", uri, exc);
    }

    // Locate the file
    return findFile(name, fileSystemOptions);
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:28,代码来源:AbstractOriginatingFileProvider.java


示例15: AbstractFileSystem

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
protected AbstractFileSystem(final FileName rootName,
                             final FileObject parentLayer,
                             final FileSystemOptions fileSystemOptions)
{
    // this.parentLayer = parentLayer;
    this.parentLayer = parentLayer;
    this.rootName = rootName;
    this.fileSystemOptions = fileSystemOptions;
    FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance();
    String uri = builder.getRootURI(fileSystemOptions);
    if (uri == null)
    {
        uri = rootName.getURI();
    }
    this.rootURI = uri;
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:17,代码来源:AbstractFileSystem.java


示例16: parseUri

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Parse the base and name into a FileName.
 * @param context The component context.
 * @param base The base FileName.
 * @param filename The target file name.
 * @return The constructed FileName.
 * @throws FileSystemException if an error occurs.
 */
public FileName parseUri(final VfsComponentContext context, FileName base, final String filename)
        throws FileSystemException
{
    final StringBuffer name = new StringBuffer();

    // Extract the scheme
    final String scheme = UriParser.extractScheme(filename, name);

    // Extract the Layered file URI
    final String rootUriName = extractRootName(name);
    FileName rootUri = null;
    if (rootUriName != null)
    {
        rootUri = context.parseURI(rootUriName);
    }

    // Decode and normalise the path
    UriParser.canonicalizePath(name, 0, name.length(), this);
    UriParser.fixSeparators(name);
    FileType fileType = UriParser.normalisePath(name);
    final String path = name.toString();

    return new LayeredFileName(scheme, rootUri, path, fileType);
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:33,代码来源:LayeredFileNameParser.java


示例17: getJunctionForFile

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Locates the junction point for the junction containing the given file.
 * @param name The FileName.
 * @return the FileName where the junction occurs.
 */
private FileName getJunctionForFile(final FileName name)
{
    if (junctions.containsKey(name))
    {
        // The name points to the junction point directly
        return name;
    }

    // Find matching junction
    for (Iterator iterator = junctions.keySet().iterator(); iterator.hasNext();)
    {
        final FileName junctionPoint = (FileName) iterator.next();
        if (junctionPoint.isDescendent(name))
        {
            return junctionPoint;
        }
    }

    // None
    return null;
}
 
开发者ID:pentaho,项目名称:pdi-vfs,代码行数:27,代码来源:VirtualFileSystem.java


示例18: doCreateFileSystem

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
/**
 * Create a file system with the S3 root provided.
 * 
 * @param fileName
 *          the S3 file name that defines the root (bucket)
 * @param fileSystemOptions
 *          file system options
 * @return an S3 file system
 * @throws FileSystemException
 *           if the file system cannot be created
 */
protected FileSystem doCreateFileSystem(FileName fileName, FileSystemOptions fileSystemOptions) throws FileSystemException {
	FileSystemOptions fsOptions = fileSystemOptions != null ? fileSystemOptions : getDefaultFileSystemOptions();
	
	// Initialize S3 service.
	UserAuthenticationData authData = null;

	try {
		// Read authData from file system options
		authData = UserAuthenticatorUtils.authenticate(fsOptions, AUTHENTICATOR_TYPES);

		// Fetch AWS key-id and secret key from authData
		String keyId 	= UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME, null));
		String secret	= UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, null));
		String domain = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.DOMAIN, null));

		if (keyId.length() + secret.length() == 0) {
			throw new FileSystemException("Empty AWS credentials");
		}
		
		// Construct S3 file system
		return new S3FileSystem( (S3FileName)fileName, new S3AwImpl(keyId,secret,domain), fsOptions);
	} finally {
		UserAuthenticatorUtils.cleanup(authData);
	}

}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:38,代码来源:S3FileProvider.java


示例19: S3FileObject

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
public S3FileObject(FileName fileName, S3FileSystem fileSystem, S3 service, String bucket) throws FileSystemException {
	super(fileName, fileSystem);
	this.service 		= service;
	this.bucket 		= bucket;
	this.fileName		= fileName;
	this.fileSystem	= fileSystem;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:8,代码来源:S3FileObject.java


示例20: getPath

import org.apache.commons.vfs.FileName; //导入依赖的package包/类
protected FileObject getPath(FileObject baseDir, FileObject currentDir, String ftpPath) throws FileSystemException
{
    FileObject prepath = null;
    try
    {
        if(ftpPath==null || ftpPath.equals("")) return currentDir;
        else if(ftpPath.charAt(0)==FileName.SEPARATOR_CHAR)
        {
            int indx = 1;
            for(;indx<ftpPath.length();indx++)
            {
                if(ftpPath.charAt(indx)!=FileName.SEPARATOR_CHAR) break;
            }
            ftpPath = ftpPath.substring(indx);
            prepath = baseDir.resolveFile(ftpPath);
        }
        else
        {
            prepath = currentDir.resolveFile(ftpPath);
        }
    }
    catch (FileSystemException e)
    {
        return baseDir;
    }
    if(baseDir.getName().isDescendent(prepath.getName()))
    {
       return prepath; 
    }
    else
    {
        return baseDir;
    }
}
 
开发者ID:PhantomYdn,项目名称:jvfsftpd,代码行数:35,代码来源:AbstractHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GLCommon类代码示例发布时间:2022-05-22
下一篇:
Java BEASTObject类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap