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


Java FileType.FILE属性代码示例

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


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

示例1: doGetType

/**
 * Determines the type of the file, returns null if the file does not
 * exist.
 */
@Override
protected FileType doGetType() throws Exception
{
    if (!file.exists())
    {
        return FileType.IMAGINARY;
    }
    else if (file.isDirectory())
    {
        return FileType.FOLDER;
    }
    else if (file.isFile())
    {
        return FileType.FILE;
    }

    throw new FileSystemException("vfs.provider.Nfs/get-type.error", getName());
}
 
开发者ID:danniss,项目名称:common-vfs2-nfs,代码行数:22,代码来源:NfsFileObject.java

示例2: doGetType

/**
 * Determines the type of the file, returns null if the file does not exist.
 * 
 * @return the file type
 * 
 * @throws Exception the exception
 */
@Override
protected FileType doGetType() throws Exception {
    // log.debug("relative path:" + relPath);

    if (this.fileInfo == null) {
        return FileType.IMAGINARY;
    } else if (this.fileInfo.isDirectory()) {
        return FileType.FOLDER;
    } else if (this.fileInfo.isFile()) {
        return FileType.FILE;
    } else if (this.fileInfo.isSoftLink()) {
        return FileType.FILE; // getLinkDestination().getType();
    }

    throw new FileSystemException("vfs.provider.gsiftp/get-type.error", getName());
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:23,代码来源:GsiFtpFileObject.java

示例3: doGetType

/**
 * Determines the type of the file, returns null if the file does not
 * exist.
 */
@Override
protected FileType doGetType() throws Exception
{
    if (part == null)
    {
        return FileType.IMAGINARY;
    }

    if (isMultipart())
    {
        // we cant have children ...
        return FileType.FILE_OR_FOLDER;
    }

    return FileType.FILE;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:20,代码来源:MimeFileObject.java

示例4: doGetType

/**
 * Determines the type of the file, returns null if the file does not
 * exist.
 */
@Override
protected FileType doGetType() throws Exception
{
    if (!file.exists())
    {
        return FileType.IMAGINARY;
    }
    else if (file.isDirectory())
    {
        return FileType.FOLDER;
    }
    else if (file.isFile())
    {
        return FileType.FILE;
    }

    throw new FileSystemException("vfs.provider.smb/get-type.error", getName());
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:22,代码来源:SmbFileObject.java

示例5: setZipEntry

/**
 * Sets the details for this file object.
 */
protected void setZipEntry(final ZipEntry entry)
{
    if (this.entry != null)
    {
        return;
    }

    if ((entry == null) || (entry.isDirectory()))
    {
        type = FileType.FOLDER;
    }
    else
    {
        type = FileType.FILE;
    }

    this.entry = entry;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:21,代码来源:ZipFileObject.java

示例6: doGetType

/**
 * Returns the file's type.
 */
@Override
protected FileType doGetType() throws Exception
{
    // JDK BUG: 6192331
    // if (!file.exists())
    if (!file.exists() && file.length() < 1)
    {
        return FileType.IMAGINARY;
    }

    if (file.isDirectory())
    {
        return FileType.FOLDER;
    }

    // In doubt, treat an existing file as file
    // if (file.isFile())
    // {
        return FileType.FILE;
    // }

    // throw new FileSystemException("vfs.provider.local/get-type.error", file);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:26,代码来源:LocalFile.java

示例7: doDelete

/**
 * Deletes the file.
 */
@Override
protected void doDelete() throws Exception
{
    final ChannelSftp channel = fileSystem.getChannel();
    try
    {
        if (getType() == FileType.FILE)
        {
            channel.rm(relPath);
        }
        else
        {
            channel.rmdir(relPath);
        }
    }
    finally
    {
        fileSystem.putChannel(channel);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:23,代码来源:SftpFileObject.java

示例8: doGetType

/**
 * Determines the type of this file.  Must not return null.  The return
 * value of this method is cached, so the implementation can be expensive.
 */
@Override
protected FileType doGetType() throws Exception
{
    // Use the HEAD method to probe the file.
    method = new HeadMethod();
    setupMethod(method);
    final HttpClient client = fileSystem.getClient();
    final int status = client.executeMethod(method);
    method.releaseConnection();
    if (status == HttpURLConnection.HTTP_OK)
    {
        return FileType.FILE;
    }
    else if (status == HttpURLConnection.HTTP_NOT_FOUND
        || status == HttpURLConnection.HTTP_GONE)
    {
        return FileType.IMAGINARY;
    }
    else
    {
        throw new FileSystemException("vfs.provider.http/head.error", getName());
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:27,代码来源:HttpFileObject.java

示例9: setTarEntry

/**
 * Sets the details for this file object.
 */
protected void setTarEntry(final TarEntry entry)
{
    if (this.entry != null)
    {
        return;
    }

    if ((entry == null) || (entry.isDirectory()))
    {
        type = FileType.FOLDER;
    }
    else
    {
        type = FileType.FILE;
    }

    this.entry = entry;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:21,代码来源:TarFileObject.java

示例10: doGetType

/** Returns the file's type. */
@Override
protected FileType doGetType() throws Exception {
    // JDK BUG: 6192331
    // if (!file.exists())
    if (!file.exists() && file.length() < 1) {
        return FileType.IMAGINARY;
    }

    if (file.isDirectory()) {
        return FileType.FOLDER;
    }

    // In doubt, treat an existing file as file
    // if (file.isFile())
    // {
    return FileType.FILE;
    // }

    // throw new FileSystemException("vfs.provider.local/get-type.error", file);
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:21,代码来源:AludraLocalFile.java

示例11: FSManager

private FSManager() throws IOException {
  fsManager = VFS.getManager();

  final FileObject basePath =
      fsManager.resolveFile(RES_PREFIX + File.separatorChar + ODataServiceVersion.V40.name());
  final String absoluteBaseFolder = basePath.getURL().getPath();

  for (FileObject fo : find(basePath, null)) {
    if (fo.getType() == FileType.FILE
        && !fo.getName().getBaseName().contains("Metadata")
        && !fo.getName().getBaseName().contains("metadata")) {
      final String path = fo.getURL().getPath().replace(absoluteBaseFolder, "//" + ODataServiceVersion.V40.name());
      putInMemory(fo.getContent().getInputStream(), path);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:16,代码来源:FSManager.java

示例12: getEnvFileToRead

private FileObject getEnvFileToRead(FileObject sourcePath) {
    if (sourcePath.getType() == FileType.FILE && sourcePath.isReadable() && sourcePath.getName().getExtension().equalsIgnoreCase("xml")) {
        return sourcePath;
    } else {
        return sourcePath.getChild("system-config.xml");
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:7,代码来源:DbEnvironmentXmlEnricher.java

示例13: moveFile

/**
 * Move the files
 *
 * @param source      Location of the file
 * @param destination Destination of the file
 * @return return a resultStatus
 */
private boolean moveFile(String source, String destination, MessageContext messageContext,
                         boolean includeParentDirectory, String filePattern) {
    boolean resultStatus = false;
    StandardFileSystemManager manager = null;
    try {
        manager = FileConnectorUtils.getManager();
        // Create remote object
        FileObject remoteFile = manager.resolveFile(source, FileConnectorUtils.init(messageContext));
        if (remoteFile.exists()) {
            if (remoteFile.getType() == FileType.FILE) {
                fileMove(destination, remoteFile, messageContext, manager);
            } else {
                folderMove(source, destination, filePattern, includeParentDirectory, messageContext, manager);
            }
            resultStatus = true;
            if (log.isDebugEnabled()) {
                log.debug("File move completed from " + source + " to " + destination);
            }
        } else {
            log.error("The file/folder location does not exist.");
            resultStatus = false;
        }
    } catch (IOException e) {
        handleException("Unable to move a file/folder.", e, messageContext);
    } finally {
        if (manager != null) {
            manager.close();
        }
    }
    return resultStatus;
}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:38,代码来源:FileMove.java

示例14: folderMove

/**
 * Move the folder
 *
 * @param destination            New location of the folder
 * @param source                 Location of the folder
 * @param messageContext         The message context that is processed by a handler in the handle method
 * @param includeParentDirectory Boolean type
 * @param manager                Standard file system manager
 */
private void folderMove(String source, String destination, String filePattern, boolean includeParentDirectory,
                        MessageContext messageContext, StandardFileSystemManager manager) throws IOException {
    FileObject remoteFile = manager.resolveFile(source, FileConnectorUtils.init(messageContext));
    FileObject file = manager.resolveFile(destination, FileConnectorUtils.init(messageContext));
    if (StringUtils.isNotEmpty(filePattern)) {
        FileObject[] children = remoteFile.getChildren();
        for (FileObject child : children) {
            if (child.getType() == FileType.FILE) {
                moveFileWithPattern(child, destination, filePattern, manager, messageContext);
            } else if (child.getType() == FileType.FOLDER) {
                String newSource = source + File.separator + child.getName().getBaseName();
                folderMove(newSource, destination, filePattern, includeParentDirectory, messageContext, manager);
            }
        }
    } else if (includeParentDirectory) {
        file = manager.resolveFile(destination + File.separator + remoteFile.getName().getBaseName(),
                FileConnectorUtils.init(messageContext));
        file.createFolder();
        remoteFile.moveTo(file);
    } else {
        if (!file.exists()) {
            file.createFolder();
        }
        remoteFile.moveTo(file);
        remoteFile.createFolder();
    }
}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:36,代码来源:FileMove.java

示例15: deleteFile

/**
 * Delete the file repsented by the file parameter.
 * 
 * @param file the file
 * 
 * @return true, if successful
 * @throws MotuException
 */
public boolean deleteFile(FileObject file) throws MotuException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("deleteFile(FileObject) - entering");
    }

    boolean deleted = false;
    try {

        if (file.exists()) {
            if (file.getType() != FileType.FILE) {
                throw new MotuException(
                        ErrorType.NETCDF_LOADING,
                        String.format("Delete file '%s' is rejected: it is a folder. ", file.getName().toString()));
            }

            deleted = file.delete();
        }
    } catch (FileSystemException e) {
        LOG.error("deleteFile(FileObject)", e);

        // throw new MotuException(String.format("Unable to copy file '%s' to '%s'",
        // foSrc.getURL().toString(), foDest.getURL().toString()), e);
        throw new MotuException(ErrorType.NETCDF_LOADING, String.format("Unable to delete '%s'", file.getName().toString()), e);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("deleteFile(FileObject) - exiting");
    }
    return deleted;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:38,代码来源:VFSManager.java


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