當前位置: 首頁>>代碼示例>>Java>>正文


Java FileObject.copyFrom方法代碼示例

本文整理匯總了Java中org.apache.commons.vfs2.FileObject.copyFrom方法的典型用法代碼示例。如果您正苦於以下問題:Java FileObject.copyFrom方法的具體用法?Java FileObject.copyFrom怎麽用?Java FileObject.copyFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.vfs2.FileObject的用法示例。


在下文中一共展示了FileObject.copyFrom方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: saveToTargetLocation

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
@Override
public void saveToTargetLocation(File tmpFile, String targetDir) throws FileSystemException, IOException {
    if (tmpFile == null)
        throw new NullPointerException("tmpFile cannot be null");

    if (!tmpFile.exists())
        throw new FileNotFoundException(
            "Unable to save file '" + tmpFile.getAbsolutePath() + "' to target location as it does not exist");

    FileObject tmpFO = null;
    FileObject targetDirFO = null;
    FileObject targetFileFO = null;

    try {
        FileSystemManager fsManager = fileSystemManager();

        // Tmp file.
        tmpFO = fsManager.resolveFile(tmpFile.getAbsolutePath());

        // Where to copy tmp file to.
        targetDirFO = get(targetDir);
        targetFileFO = get(new File(targetDir, tmpFile.getName()).getAbsolutePath());

        // Attempt to create directories if they do not exist.
        if (!targetDirFO.exists())
            targetDirFO.createFolder();

        if (targetDirFO.exists()) {
            log.info("Saving file'" + tmpFO.getURL() + "' to '" + targetFileFO.getURL() + "'.");

            targetFileFO.copyFrom(tmpFO, Selectors.SELECT_SELF);
        } else {
            throw new FileSystemException(
                "Attempt to create target dir '" + targetDirFO.getURL().toString() + "' failed");
        }

        if (targetDirFO == null || !targetDirFO.exists())
            throw new FileSystemException("Tmp file '" + tmpFO.getURL()
                + "' could not be copied to target locaton '" + targetFileFO.getURL() + "'");
    } finally {
        close(tmpFO);
        close(targetDirFO);
        close(targetFileFO);
    }
}
 
開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:46,代碼來源:DefaultVfsHelper.java

示例2: copyFrom

import org.apache.commons.vfs2.FileObject; //導入方法依賴的package包/類
/**
 * Copy from.
 * 
 * @param srcFile the src file
 * @param destFile the dest file
 * @param selector the selector
 * @throws FileSystemException the file system exception
 */
public void copyFrom(FileObject srcFile, FileObject destFile, FileSelector selector) throws FileSystemException {

    // MIS-203
    refreshFtpCache(srcFile);

    destFile.copyFrom(srcFile, selector);

}
 
開發者ID:clstoulouse,項目名稱:motu,代碼行數:17,代碼來源:VFSManager.java


注:本文中的org.apache.commons.vfs2.FileObject.copyFrom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。