本文整理汇总了Java中org.apache.commons.vfs.FileType类的典型用法代码示例。如果您正苦于以下问题:Java FileType类的具体用法?Java FileType怎么用?Java FileType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileType类属于org.apache.commons.vfs包,在下文中一共展示了FileType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseUri
import org.apache.commons.vfs.FileType; //导入依赖的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);
}
示例2: handle
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
public FtpReplay handle(String command, String params)
throws CommandException, FileSystemException
{
String arg = params;
FileObject file = getPath(arg);
if (!file.exists())
throw new CommandException(550, arg + ": no such file");
if (file.getType().equals(FileType.FOLDER))
throw new CommandException(550, arg + ": not a plain file");
Representation representation = getServerPI().dtp.getRepresentation();
long size;
try
{
size = representation.sizeOf(file);
}
catch (IOException e)
{
throw new CommandException(550, e.getMessage());
}
// XXX: in ascii mode, we must count newlines properly
return FtpReplay.createReplay(213, "{0}",size);
}
示例3: service
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
FileObject object = VFSBackend.resolveFile(request.getPathInfo());
if (object.exists()) {
if (FileType.FOLDER.equals(object.getType())) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
setHeader(response, object.getContent());
InputStream is = object.getContent().getInputStream();
OutputStream os = response.getOutputStream();
Util.copyStream(is, os);
is.close();
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
示例4: service
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setHeader("DAV", "1, 2");
String path = request.getPathInfo();
StringBuffer options = new StringBuffer();
FileObject object = VFSBackend.resolveFile(path);
if (object.exists()) {
options.append("OPTIONS, GET, HEAD, POST, DELETE, TRACE, COPY, MOVE, LOCK, UNLOCK, PROPFIND");
if (FileType.FOLDER.equals(object.getType())) {
options.append(", PUT");
}
} else {
options.append("OPTIONS, MKCOL, PUT, LOCK");
}
response.setHeader("Allow", options.toString());
// see: http://www-128.ibm.com/developerworks/rational/library/2089.html
response.setHeader("MS-Author-Via", "DAV");
}
示例5: getFileType
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
public FileType getFileType(String filename) throws KettleJobException
{
try {
SftpATTRS attrs=c.stat(filename);
if (attrs == null) return FileType.IMAGINARY;
if ((attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS) == 0)
throw new KettleJobException("Unknown permissions error");
if (attrs.isDir())
return FileType.FOLDER;
else
return FileType.FILE;
} catch (Exception e) {
throw new KettleJobException(e);
}
}
示例6: FileExists
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
/**
* Check existence of a local file
*
* @param filename
* @return true, if file exists
*/
public boolean FileExists(String filename) {
FileObject file=null;
try {
file=KettleVFS.getFileObject(filename);
if(!file.exists()) return false;
else
{
if(file.getType() == FileType.FILE) return true;
else return false;
}
} catch (Exception e) {
return false;
}
}
示例7: getFiles
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
private List<FileObject> getFiles(String localfolder) throws IOException
{
List<FileObject> myFileList = new ArrayList<FileObject>();
// Get all the files in the local directory...
FileObject localFiles = KettleVFS.getFileObject(localfolder);
FileObject[] children = localFiles.getChildren();
if (children!=null)
{
for (int i=0; i<children.length; i++)
{
// Get filename of file or directory
if (children[i].getType().equals(FileType.FILE))
{
myFileList.add(children[i]);
}
} // end for
}
return myFileList;
}
示例8: includeFile
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
public boolean includeFile(FileSelectInfo info)
{
boolean returncode=false;
try
{
if (!info.getFile().toString().equals(source_folder))
{
// Pass over the Base folder itself
String short_filename= info.getFile().getName().getBaseName();
if (info.getFile().getParent().equals(info.getBaseFolder()) ||
(!info.getFile().getParent().equals(info.getBaseFolder()) && includeSubfolders))
{
if((info.getFile().getType() == FileType.FILE && file_wildcard==null) ||
(info.getFile().getType() == FileType.FILE && file_wildcard!=null && GetFileWildcard(short_filename,file_wildcard)))
returncode=true;
}
}
}
catch (Exception e)
{
log.logError(toString(), "Error while finding files ... in [" + info.getFile().toString() + "]. Exception :"+e.getMessage());
returncode= false;
}
return returncode;
}
示例9: includeFile
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
public boolean includeFile(FileSelectInfo info)
{
boolean returncode=false;
try
{
if (!info.getFile().toString().equals(source_folder))
{
// Pass over the Base folder itself
String short_filename= info.getFile().getName().getBaseName();
if (info.getFile().getParent().equals(info.getBaseFolder()) ||
((!info.getFile().getParent().equals(info.getBaseFolder()) && meta.isIncludeSubFolders())))
{
if((info.getFile().getType() == FileType.FILE && file_wildcard==null) ||
(info.getFile().getType() == FileType.FILE && file_wildcard!=null && GetFileWildcard(short_filename,file_wildcard)))
returncode=true;
}
}
}
catch (Exception e)
{
log.logError(toString(), Messages.getString("Mail.Error.FindingFiles", info.getFile().toString(),e.getMessage()));
returncode= false;
}
return returncode;
}
示例10: FileExists
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
/**
* Check existence of a local file
*
* @param filename
* @return true, if file exists
*/
public boolean FileExists(String filename) {
FileObject file=null;
try {
file=KettleVFS.getFileObject(filename, this);
if(!file.exists()) return false;
else
{
if(file.getType() == FileType.FILE) return true;
else return false;
}
} catch (Exception e) {
return false;
}
}
示例11: includeFile
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
public boolean includeFile(FileSelectInfo info)
{
boolean returncode=false;
try
{
if (!info.getFile().toString().equals(source_folder))
{
// Pass over the Base folder itself
String short_filename= info.getFile().getName().getBaseName();
if (info.getFile().getParent().equals(info.getBaseFolder()) ||
(!info.getFile().getParent().equals(info.getBaseFolder()) && includeSubfolders))
{
if((info.getFile().getType() == FileType.FILE && file_wildcard==null) ||
(info.getFile().getType() == FileType.FILE && file_wildcard!=null && GetFileWildcard(short_filename,file_wildcard)))
returncode=true;
}
}
}
catch (Exception e)
{
logError("Error while finding files ... in [" + info.getFile().toString() + "]. Exception :"+e.getMessage());
returncode= false;
}
return returncode;
}
示例12: loadRepositoryDirectoryTree
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
public RepositoryDirectoryInterface loadRepositoryDirectoryTree(RepositoryDirectoryInterface dir) throws KettleException {
try {
String folderName = calcDirectoryName(dir);
FileObject folder = KettleVFS.getFileObject(folderName);
for (FileObject child : folder.getChildren()) {
if (child.getType().equals(FileType.FOLDER)) {
if (!child.isHidden() || !repositoryMeta.isHidingHiddenFiles()) {
RepositoryDirectory subDir = new RepositoryDirectory(dir, child.getName().getBaseName());
subDir.setObjectId(new StringObjectId(calcObjectId(subDir)));
dir.addSubdirectory(subDir);
loadRepositoryDirectoryTree(subDir);
}
}
}
return dir;
}
catch(Exception e) {
throw new KettleException("Unable to load the directory tree from this file repository", e);
}
}
示例13: includeFile
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
public boolean includeFile(FileSelectInfo info)
{
boolean returncode=false;
try
{
if (!info.getFile().toString().equals(source_folder))
{
// Pass over the Base folder itself
String short_filename= info.getFile().getName().getBaseName();
if (info.getFile().getParent().equals(info.getBaseFolder()) ||
((!info.getFile().getParent().equals(info.getBaseFolder()) && meta.isIncludeSubFolders())))
{
if((info.getFile().getType() == FileType.FILE && file_wildcard==null) ||
(info.getFile().getType() == FileType.FILE && file_wildcard!=null && GetFileWildcard(short_filename,file_wildcard)))
returncode=true;
}
}
}
catch (Exception e)
{
logError(BaseMessages.getString(PKG, "Mail.Error.FindingFiles", info.getFile().toString(),e.getMessage()));
returncode= false;
}
return returncode;
}
示例14: handleDelete
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
/**
* Called when this file is deleted. Updates cached info and notifies
* subclasses, parent and file system.
*/
protected void handleDelete() throws Exception
{
synchronized (fs)
{
if (attached)
{
// Fix up state
injectType(FileType.IMAGINARY);
removeChildrenCache();
// children = null;
// Notify subclass
onChange();
}
// Notify parent that its child list may no longer be valid
notifyParent(this.getName(), FileType.IMAGINARY);
// Notify the file system
fs.fireFileDeleted(this);
}
}
示例15: doGetType
import org.apache.commons.vfs.FileType; //导入依赖的package包/类
/**
* Determines the type of the file, returns null if the file does not
* exist.
*/
protected FileType doGetType() throws FileSystemException
{
if (file != null)
{
return file.getType();
}
else if (children.size() > 0)
{
return FileType.FOLDER;
}
else
{
return FileType.IMAGINARY;
}
}