本文整理汇总了Java中org.apache.commons.vfs2.FileObject.delete方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.delete方法的具体用法?Java FileObject.delete怎么用?Java FileObject.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.vfs2.FileObject
的用法示例。
在下文中一共展示了FileObject.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
/**
* Delete all descendents of this file that match a selector.
*
* @param file the file
* @param selector the selector
*
* @return true, if successful
* @throws MotuException
*/
public boolean delete(FileObject file, FileSelector selector) throws MotuException {
if (LOG.isDebugEnabled()) {
LOG.debug("delete(FileObject, FileSelector) - entering");
}
int deleted = 0;
try {
if (file.exists()) {
deleted = file.delete(selector);
}
} catch (FileSystemException e) {
LOG.error("delete(FileObject, FileSelector)", 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);
}
boolean returnboolean = (deleted > 0);
if (LOG.isDebugEnabled()) {
LOG.debug("delete(FileObject, FileSelector) - exiting");
}
return returnboolean;
}
示例2: remove
import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
@Override
public void remove(String noteId) throws IOException {
FileObject rootDir = fsManager.resolveFile(getPath("/"));
FileObject noteDir = rootDir.resolveFile(noteId, NameScope.CHILD);
if (!noteDir.exists()) {
// nothing to do
return;
}
if (!isDirectory(noteDir)) {
// it is not look like zeppelin note savings
throw new IOException("Can not remove " + noteDir.getName().toString());
}
noteDir.delete(Selectors.SELECT_SELF_AND_CHILDREN);
}
示例3: delete
import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
/**
* Deletes the data stored in the given file object from the store
*
* @param fo
* the file object to be deleted
*/
void delete(FileObject fo) throws IOException {
FileObject parent = fo.getParent();
fo.delete(Selectors.SELECT_ALL);
while (!parent.equals(baseDirectory)) {
final FileObject[] children = parent.getChildren();
if (children.length > 0) {
break;
}
fo = parent;
parent = fo.getParent();
fo.delete();
}
}
示例4: doDeleteContent
import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
@Override
protected void doDeleteContent(String storageId) throws Exception {
FileObject targetObject = fsManager.resolveFile(getBase(), storageId);
LOGGER.debug("Delete fired on: {}", targetObject);
LOGGER.debug("targetObject.class = {}", targetObject.getClass().getName());
if (targetObject.delete()) {
LOGGER.debug("Delete of {} was successful.", targetObject);
} else {
LOGGER.warn("Delete of {} was NOT successful (w/o errors given).", targetObject);
}
}
示例5: deleteFile
import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
/**
* 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;
}