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


Java FileUtils.moveDirectory方法代碼示例

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


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

示例1: execution

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
@Override
protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) {
    // TODO Validation must be done here!!! In case none has been set!
    File filesFrom = getAbsoluteFile(transformedAppFolder, transformationContext);
    File fileTo = getFileTo(transformedAppFolder, transformationContext);
    TOExecutionResult result = null;

    try {
        FileUtils.moveDirectory(filesFrom, fileTo);
        String details = String.format("Directory '%s' has been moved to '%s'", getRelativePath(transformedAppFolder, filesFrom), getRelativePath(transformedAppFolder, fileTo));
        result = TOExecutionResult.success(this, details);
    } catch (IOException e) {
        result = TOExecutionResult.error(this, e);
    }

    return result;
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:18,代碼來源:MoveDirectory.java

示例2: unzipApk

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
/**
 * unzip 2 apk file
 *
 * @param outPatchDir
 */
protected File unzipApk(File outPatchDir) throws IOException {
    File unzipFolder = new File(outPatchDir, "unzip");
    if (!unzipFolder.exists()){
        unzipFolder.mkdirs();
    }
    File baseApkUnzipFolder = new File(unzipFolder, BASE_APK_UNZIP_NAME);
    File newApkUnzipFolder = new File(unzipFolder, NEW_APK_UNZIP_NAME);
    CommandUtils.exec(outPatchDir,"unzip "+input.baseApkBo.getApkFile().getAbsolutePath()+" -d "+baseApkUnzipFolder.getAbsolutePath());

    if (input.newApkBo.getApkFile().isDirectory()){
        FileUtils.moveDirectory(input.newApkBo.getApkFile(), newApkUnzipFolder);
    }else {
        CommandUtils.exec(outPatchDir,"unzip "+input.newApkBo.getApkFile().getAbsolutePath()+" -d "+ newApkUnzipFolder.getAbsolutePath());
    }

    return unzipFolder;
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:23,代碼來源:AbstractTool.java

示例3: unzipFile

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
private File unzipFile(File cachedFile) throws IOException {
  String filename = cachedFile.getName();
  File destDir = new File(cachedFile.getParentFile(), filename + "_unzip");
  if (!destDir.exists()) {
    File lockFile = new File(cachedFile.getParentFile(), filename + "_unzip.lock");
    FileOutputStream out = new FileOutputStream(lockFile);
    try {
      FileLock lock = out.getChannel().lock();
      try {
        // Recheck in case of concurrent processes
        if (!destDir.exists()) {
          Path tempDir = fileCache.createTempDir();
          ZipUtils.unzip(cachedFile, tempDir.toFile(), newLibFilter());
          FileUtils.moveDirectory(tempDir.toFile(), destDir);
        }
      } finally {
        lock.release();
      }
    } finally {
      out.close();
      FileUtils.deleteQuietly(lockFile);
    }
  }
  return destDir;
}
 
開發者ID:instalint-org,項目名稱:instalint,代碼行數:26,代碼來源:DefaultPluginJarExploder.java

示例4: moveDirectory

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public static void moveDirectory(File source, File destination) {
    try {
        FileUtils.moveDirectory(source, destination);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:8,代碼來源:GFileUtils.java

示例5: move_to_csap_saved_folder

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public void move_to_csap_saved_folder ( File folder_to_backup, StringBuilder operation_output )
		throws IOException {

	File csapSavedFolder = getCsapSavedFolder();

	String now = LocalDateTime.now().format( DateTimeFormatter.ofPattern( "MMM.d-HH.mm.ss" ) );

	File backUpFolder = new File( csapSavedFolder, folder_to_backup.getName() + "." + now );

	if ( backUpFolder.exists() ) {
		logger.info( "Warning: agent jobs are not cleaning up: {}", backUpFolder.getAbsolutePath() );
		FileUtils.deleteQuietly( backUpFolder );
		operation_output.append( "\n\n Deleting previous backup: " + backUpFolder.getAbsolutePath() + "\n" );
	}

	if ( folder_to_backup.exists() ) {

		logger.info( "Moving: {} to {}", folder_to_backup.getAbsolutePath(), backUpFolder.getAbsolutePath() );

		operation_output.append( "\n\n Moving : "
				+ folder_to_backup.getAbsolutePath()
				+ " to: "
				+ backUpFolder.getAbsolutePath() + "\n" );

		FileUtils.moveDirectory( folder_to_backup, backUpFolder );
	} else {
		operation_output.append( "Folder does not exist: " + folder_to_backup.getCanonicalPath() );
		logger.warn( "Folder does not exist: {}", folder_to_backup.getCanonicalPath() );

	}
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:32,代碼來源:Application.java

示例6: deleteCollection

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public void deleteCollection(String collectionName) {
    try {
        File directory = new File(resolver.getCollectionPath(collectionName));
        File renamed = new File(System.getProperty("java.io.tmpdir") + "/" + collectionName);

        if(!directory.exists()) return;

        FileUtils.moveDirectory(directory, renamed);
        FileUtils.deleteDirectory(renamed);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:AntonioGabrielAndrade,項目名稱:LIRE-Lab,代碼行數:14,代碼來源:CollectionTestHelper.java

示例7: moveFolder

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
/**
 * 移動目錄
 * @author Rocye
 * @param srcPath 	移動目錄的源路徑
 * @param destPath 	移動目錄的目的路徑
 * @param isMoveRoot 是否移動根目錄 true 為移動根目錄 false 為不移動根目錄,隻移動根目錄下的所有文件以及文件夾
 * @return true OR false
 * @version 2017-02-28
 */
public static boolean moveFolder(String srcPath, String destPath, boolean isMoveRoot) {
	try {
		if(isMoveRoot){
			FileUtils.moveDirectoryToDirectory(new File(srcPath), new File(destPath), true);
		}else{
			FileUtils.moveDirectory(new File(srcPath), new File(destPath));
		}
		return true;
	} catch (IOException e) {
		e.printStackTrace();
		logger.error("調用ApacheCommon移動文件夾時:" + e.toString());
		return false;
	}
}
 
開發者ID:rocye,項目名稱:wx-idk,代碼行數:24,代碼來源:FileIo.java

示例8: pushArtifactsToLocalRepo

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
private void pushArtifactsToLocalRepo(Plugin plugin) {
    try {

        String latestGitTag = plugin.getTag();

        Path cachePath = gitCachePath(plugin);

        // default outputs is dist folder
        Path artifactPath = Paths.get(cachePath.toString(), DIST);

        // create tmp folder to store build outputs
        Path tmp = Paths.get(gitCacheWorkspace.toString(), "tmp");
        if (!tmp.toFile().exists()) {
            Files.createDirectories(tmp);
        }

        // move artifacts to tmp folder
        Path actPath = Paths.get(tmp.toString(), DIST);
        if (actPath.toFile().exists()) {
            FileUtils.deleteDirectory(actPath.toFile());
        }
        FileUtils.moveDirectory(artifactPath.toFile(), actPath.toFile());

        Path localPath = gitRepoPath(plugin);

        // init git and push tags
        JGitUtil.init(actPath, false);
        JGitUtil.remoteSet(actPath, LOCAL_REMOTE, localPath.toString());
        Git git = Git.open(actPath.toFile());

        git.add()
            .addFilepattern(".")
            .call();

        git.commit()
            .setMessage("add build outputs")
            .call();

        git.tag()
            .setName(plugin.getTag())
            .setMessage("add " + plugin.getTag())
            .call();

        JGitUtil.push(actPath, LOCAL_REMOTE, latestGitTag);
        // set currentTag latestTag
        plugin.setCurrentTag(latestGitTag);
        updatePluginStatus(plugin, INSTALLED);

        // delete path
        FileUtils.deleteDirectory(actPath.toFile());
    } catch (Throwable e) {

    }

}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:56,代碼來源:PluginServiceImpl.java

示例9: renameExistingSharedConfigDirectory

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
public void renameExistingSharedConfigDirectory() {
  File configDirFile = new File(configDirPath);
  if (configDirFile.exists()) {
    String configDirFileName2 = CLUSTER_CONFIG_ARTIFACTS_DIR_NAME
        + new SimpleDateFormat("yyyyMMddhhmm").format(new Date()) + "." + System.nanoTime();
    File configDirFile2 = new File(configDirFile.getParent(), configDirFileName2);
    try {
      FileUtils.moveDirectory(configDirFile, configDirFile2);
    } catch (IOException e) {
      logger.info(e);
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:14,代碼來源:ClusterConfigurationService.java

示例10: prepare

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
protected ManagedJvmBuilder prepare() {
    final String backupExtension = "." + System.currentTimeMillis();
    if (getStagingDir().exists()) {
        try {
            File backUp = new File(getStagingDir() + backupExtension);
            LOGGER.debug("Dir {} already exists. Backing it up to {}", getStagingDir().getAbsoluteFile(), backUp.getAbsoluteFile());
            FileUtils.moveDirectory(getStagingDir(), backUp);
        } catch (IOException e) {
            throw new JvmServiceException(e);
        }
    }

    return this;
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:15,代碼來源:ManagedJvmBuilder.java

示例11: doApkBuild

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
@TaskAction
public void doApkBuild() throws Exception {

    //TODO Merge 2 zip packages
    apkFile = getApkFile();
    diffAPkFile = getDiffAPkFile();

    Profiler.start("build tpatch apk");

    Profiler.enter("prepare dir");
    File tmpWorkDir = new File(diffAPkFile.getParentFile(), "tmp-apk");
    if (tmpWorkDir.exists()) {
        FileUtils.deleteDirectory(tmpWorkDir);
    }
    if (!tmpWorkDir.exists()) {
        tmpWorkDir.mkdirs();
    }

    BetterZip.unzipDirectory(apkFile,tmpWorkDir);

    //Map zipEntityMap = new HashMap();
    //ZipUtils.unzip(apkFile, tmpWorkDir.getAbsolutePath(), "UTF-8", zipEntityMap, true);

    FileUtils.deleteDirectory(new File(tmpWorkDir, "assets"));
    FileUtils.deleteDirectory(new File(tmpWorkDir, "res"));
    FileUtils.forceDelete(new File(tmpWorkDir, "resources.arsc"));
    FileUtils.forceDelete(new File(tmpWorkDir, "AndroidManifest.xml"));

    File resdir = new File(diffAPkFile.getParentFile(), "tmp-diffResAp");
    resdir.mkdirs();
    ZipUtils.unzip(getResourceFile(), resdir.getAbsolutePath(), "UTF-8", new HashMap<String, ZipEntry>(), true);

    FileUtils.copyDirectory(resdir, tmpWorkDir);

    Profiler.release();

    Profiler.enter("rezip");

    if (getProject().hasProperty("atlas.createDiffApk")) {
        BetterZip.zipDirectory(tmpWorkDir, diffAPkFile);
    }else {
        FileUtils.moveDirectory(tmpWorkDir,diffAPkFile);
    }

    //ZipUtils.rezip(diffAPkFile, tmpWorkDir, zipEntityMap);
    Profiler.release();

    FileUtils.deleteDirectory(tmpWorkDir);
    FileUtils.deleteDirectory(resdir);

    getLogger().warn(Profiler.dump());

}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:54,代碼來源:TPatchDiffApkBuildTask.java

示例12: doActionForSourceDirectory

import org.apache.commons.io.FileUtils; //導入方法依賴的package包/類
@Override
protected void doActionForSourceDirectory(File sourceFile, File destinationFile) throws IOException {
	FileUtils.moveDirectory(sourceFile, destinationFile);
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:5,代碼來源:MoveStep.java


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