本文整理匯總了Java中org.apache.commons.vfs2.FileObject.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java FileObject.getParent方法的具體用法?Java FileObject.getParent怎麽用?Java FileObject.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.vfs2.FileObject
的用法示例。
在下文中一共展示了FileObject.getParent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: refreshFtpCache
import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
/**
* Refresh ftp cache.
*
* @param fileObject the file object
* @throws FileSystemException
*/
public void refreshFtpCache(FileObject fileObject) throws FileSystemException {
if (fileObject == null) {
return;
}
if (!(fileObject.getFileSystem() instanceof FtpFileSystem)) {
return;
}
if (fileObject.exists()) {
return;
}
FileObject fileObjectParent = fileObject.getParent();
if (fileObjectParent == null) {
return;
}
fileObjectParent.getType(); // force to attach : needed for force refresh
fileObjectParent.refresh();
}
示例2: 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();
}
}