当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.copyFileToDirectory方法代码示例

本文整理汇总了Java中org.apache.commons.io.FileUtils.copyFileToDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.copyFileToDirectory方法的具体用法?Java FileUtils.copyFileToDirectory怎么用?Java FileUtils.copyFileToDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.FileUtils的用法示例。


在下文中一共展示了FileUtils.copyFileToDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: installPackage

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void installPackage(Uri localApkUri, Uri downloadUri, Apk apk) {
    Utils.debugLog(TAG, "Installing: " + localApkUri.getPath());
    installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_STARTED);
    File path = apk.getMediaInstallPath(activity.getApplicationContext());
    path.mkdirs();
    try {
        FileUtils.copyFileToDirectory(new File(localApkUri.getPath()), path);
    } catch (IOException e) {
        Utils.debugLog(TAG, "Failed to copy: " + e.getMessage());
        installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED);
    }
    if (apk.isMediaInstalled(activity.getApplicationContext())) { // Copying worked
        Utils.debugLog(TAG, "Copying worked: " + localApkUri.getPath());
        Toast.makeText(this, String.format(this.getString(R.string.app_installed_media), path.toString()),
                Toast.LENGTH_LONG).show();
        installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_COMPLETE);
    } else {
        installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED);
    }
    finish();
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:22,代码来源:FileInstallerActivity.java

示例2: copy

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void copy(final File source, final File destination) throws IOException {

        if (!source.exists()) { throw new FileNotFoundException("source " + source + "does not exist"); }

        if (source.isFile() && !source.getAbsolutePath().equals(destination.getAbsolutePath())) {
            LOGGER.debug("copying file {}, to {}", source, destination);
            if (destination.isDirectory()) {
                if (!source.getParentFile().getAbsolutePath().equals(destination.getAbsolutePath())) {
                    FileUtils.copyFileToDirectory(source, destination);
                }
            }
            else {
                FileUtils.copyFile(source, destination);
            }
        }
        else if (source.isDirectory() && !source.getAbsolutePath().equals(destination.getAbsolutePath())) {
            LOGGER.debug("copying directory {}, to {}", source, destination);
            FileUtils.copyDirectory(source, new File(destination, source.getName()));
        }
    }
 
开发者ID:stacs-srg,项目名称:shabdiz,代码行数:21,代码来源:LocalHost.java

示例3: updateOfFileAdd

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * 新增文件的升级操作
 * @param conf
 */
private void updateOfFileAdd(Map<String,Object> conf, String updateDir) throws IOException {
    if(conf != null){
        Set<String> keys = conf.keySet();//key是更新服务器上的文件
        for (String key : keys) {
            String targetDir = String.valueOf(conf.get(key));//value是需要被添加的目录
            if(!StringUtils.isEmpty(targetDir)){
                File updateFile = new File(updateDir + File.separator + key);
                File destDir = new File(agentHome + File.separator + targetDir);
                boolean update = true;
                if(!updateFile.exists()){
                    log.error("{}update file '{}' is not exist",log4UpdateStart,updateFile.getAbsolutePath());
                    update = false;
                }
                if(!destDir.exists()){
                    log.error("{}update dir '{}' is not exist",log4UpdateStart,destDir.getAbsolutePath());
                    update = false;
                }
                if(update){
                    FileUtils.copyFileToDirectory(updateFile,destDir);
                    log.info("{}add file '{}' to dir '{}' <SUCCESS>",log4UpdateStart,updateFile.toPath().getFileName(),destDir.getAbsolutePath());
                }
            }
        }
    }
}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:30,代码来源:Update.java

示例4: updateReportHistoryData

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * updates the history of execution report
 */
@SuppressWarnings("unchecked")
private void updateReportHistoryData() {
    File file = new File(FilePath.getCurrentReportHistoryDataPath());
    ObjectMapper objectMapper = new ObjectMapper();
    String name = "var reportName=\"" + RunManager.getGlobalSettings().getRelease() + ":"
            + RunManager.getGlobalSettings().getTestSet() + "\";";
    String varaible = "var dataSet=";
    ArrayList<Map<String, String>> reportlist = new ArrayList<>();
    try {
        FileUtils.copyFileToDirectory(new File(FilePath.getReportHistoryHTMLPath()),
                new File(FilePath.getCurrentResultsLocation()));
        if (file.exists()) {
            String value = FileUtils.readFileToString(file, Charset.defaultCharset());
            value = value.replace(name, "").replace(varaible, "");
            reportlist = objectMapper.readValue(value, ArrayList.class);
        } else {
            file.createNewFile();
        }
        reportlist.add(getReportData());
        String jsonVal = objectMapper.writeValueAsString(reportlist);
        FileUtils.writeStringToFile(file, name + varaible + jsonVal, Charset.defaultCharset());
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:29,代码来源:HtmlSummaryHandler.java

示例5: copyToDirectory

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * Copies the db file and all associated files to the given directory
 * @param  destination  The destination directory
 */
DatabaseFile copyToDirectory(Path destination) throws IOException {
	Logger.details("-> " + this.getName());
	
	DatabaseFile dest = new DatabaseFile(Paths.get(destination.toString(), this.getName()));
	FileUtils.copyFile((File) this, dest);
	
	File wal = new File(this.getAbsolutePath() + "-wal");
	if (wal.exists()) {
		Logger.details("-> " + wal.getName());
		FileUtils.copyFileToDirectory(wal, destination.toFile());
	}
	
	File shm = new File(this.getAbsolutePath() + "-shm");
	if (shm.exists()) {
		Logger.details("-> " + shm.getName());
		FileUtils.copyFileToDirectory(shm, destination.toFile());
	}
	
	return dest;
}
 
开发者ID:woubuc,项目名称:WurmMapGen,代码行数:25,代码来源:FileManager.java

示例6: proceess

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public ProcessorResult proceess(Image image, RuntimeConfiguration configuration) {
    List<UploadFile> files =  image.getAllFiles();
    if(!CollectionUtils.isEmpty(files)){
        for(UploadFile file : files) {
            if(!configuration.getWorkspace().equals(file.getPath())) {
                try {

                    FileUtils.copyFileToDirectory(new File(file.getPath()+"/"+file.getFileName()), new File(configuration.getWorkspace()));
                } catch (IOException e) {
                    e.printStackTrace();

                    logger.info("cannot move fileName from {} to {}",file.getPath()+"/"+file.getFileName(), configuration.getWorkspace());
                    return new ProcessorResult(image, configuration).error("cannot move fileName from "+file.getPath()+"/"+file.getFileName()+ "to "+configuration.getWorkspace());
                }
            }
        }
    }
    return new ProcessorResult(image, configuration).success();
}
 
开发者ID:BaiduQA-SETI,项目名称:docker-image-builder,代码行数:21,代码来源:FileCopyProcessor.java

示例7: loadResource

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public void loadResource(IosCredentialDetail detail, Path tmp) {
    Path zipPath = Paths.get(tmp.toString() + ZIP_SUFFIX);
    File targetFile = new File(zipPath.toString());

    try {
        for (PasswordFileResource passwordFileResource : detail.getP12s()) {
            FileUtils.copyFileToDirectory(Paths.get(passwordFileResource.getPath()).toFile(), tmp.toFile());
        }

        for (FileResource fileResource : detail.getProvisionProfiles()) {
            FileUtils.copyFileToDirectory(Paths.get(fileResource.getPath()).toFile(), tmp.toFile());
        }

        ZipUtil.zipFolder(tmp.toFile(), targetFile);
    } catch (IOException e) {
        throw new FlowException("Io exception " + ExceptionUtil.findRootCause(e));
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:20,代码来源:CredentialServiceImpl.java

示例8: launchVM

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public synchronized void launchVM(String version, int vmNum, boolean bouncedVM)
    throws IOException {
  if (processes.containsKey(vmNum)) {
    throw new IllegalStateException("VM " + vmNum + " is already running.");
  }

  String[] cmd = buildJavaCommand(vmNum, namingPort, version);
  System.out.println("Executing " + Arrays.toString(cmd));
  File workingDir = getVMDir(version, vmNum);
  if (!workingDir.exists()) {
    workingDir.mkdirs();
  } else if (!bouncedVM || DUnitLauncher.MAKE_NEW_WORKING_DIRS) {
    try {
      FileUtil.delete(workingDir);
    } catch (IOException e) {
      // This delete is occasionally failing on some platforms, maybe due to a lingering
      // process. Allow the process to be launched anyway.
      System.err.println("Unable to delete " + workingDir + ". Currently contains "
          + Arrays.asList(workingDir.list()));
    }
    workingDir.mkdirs();
  }
  if (log4jConfig != null) {
    FileUtils.copyFileToDirectory(log4jConfig, workingDir);
  }

  // TODO - delete directory contents, preferably with commons io FileUtils
  Process process = Runtime.getRuntime().exec(cmd, null, workingDir);
  pendingVMs++;
  ProcessHolder holder = new ProcessHolder(process);
  processes.put(vmNum, holder);
  linkStreams(version, vmNum, holder, process.getErrorStream(), System.err);
  linkStreams(version, vmNum, holder, process.getInputStream(), System.out);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:35,代码来源:ProcessManager.java

示例9: processBundleFiles

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * process bundle files
 *
 * @param newBundleFile
 * @param baseBundleFile
 * @param patchTmpDir
 * @param diffTxtFile
 */
public void processBundleFiles(File newBundleFile,
                                File baseBundleFile,
                                File patchTmpDir) throws Exception {
    String bundleName = FilenameUtils.getBaseName(newBundleFile.getName());
    File destPatchBundleDir = new File(patchTmpDir, bundleName);
    final File newBundleUnzipFolder = new File(newBundleFile.getParentFile(), bundleName);
    final File baseBundleUnzipFolder = new File(baseBundleFile.getParentFile(), bundleName);

    DiffType modifyType = getModifyType(newBundleFile.getName());

    long startTime = System.currentTimeMillis();

    logger.warning(">>> start to process bundle for patch " + bundleName + " >> difftype " + modifyType.toString() + " createALl:" + ((TpatchInput)input).createAll);

    if (modifyType == DiffType.ADD) {

        FileUtils.copyFileToDirectory(newBundleFile, patchTmpDir);

    } else if (((TpatchInput)input).createAll || (modifyType == DiffType.MODIFY) )  {

        if (null != baseBundleFile &&
            baseBundleFile.isFile() &&
            baseBundleFile.exists() &&
            !((TpatchInput)input).noPatchBundles.contains(baseBundleFile.getName()
                                         .replace("_", ".")
                                         .substring(3,
                                                    baseBundleFile.getName().length() -
                                                        3)) &&
            input.diffBundleDex) {
            doBundlePatch(newBundleFile, baseBundleFile, patchTmpDir, bundleName, destPatchBundleDir,
                          newBundleUnzipFolder,
                          baseBundleUnzipFolder);
        }
    }

    logger.warning(">>> fininsh to process bundle for patch " + bundleName + " >> difftype " + modifyType.toString() + " consume:" + (System.currentTimeMillis() - startTime));
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:46,代码来源:TPatchTool.java

示例10: createHtmls

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void createHtmls() throws IOException {
    FileUtils.copyFileToDirectory(new File(FilePath.getSummaryHTMLPath()),
            new File(FilePath.getCurrentResultsPath()));
    FileUtils.copyFileToDirectory(new File(FilePath.getDetailedHTMLPath()),
            new File(FilePath.getCurrentResultsPath()));
    if (perf != null) {
        perf.exportReport();
        FileUtils.copyFileToDirectory(new File(FilePath.getPerfReportHTMLPath()),
                new File(FilePath.getCurrentResultsPath()));
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:12,代码来源:HtmlSummaryHandler.java

示例11: getDBBackup

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void getDBBackup() {
    try {
        BackupResponse res = this.backupService.dispatch(new BackupRequest());
        if (res.isSuccess()) {
        	// move backup to log directory
            FileUtils.copyFileToDirectory(this.backupService.getEncryptedBackupFile(), new File("log" + File.separator));
            this.backupService.deleteBackupFiles();
            log.info("Backup Successful! adding backup file to Support Bundle");
        }
    } catch (Exception e) {
        log.error("Failed to add DB backup in support bundle", e);
    }

}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:15,代码来源:SummaryLayout.java

示例12: test2

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test(description = "Проверка чтения дерева логов")
    public void test2() throws ParseException, IOException {
        LogFilesStructure logFilesStructure = new LogFilesStructure();
        String path = "c:\\temp\\";
        Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2017-02-17");
        HashMap<String, ArrayList<String>> logAfterDate = logFilesStructure.getLogAfterDate(date);

        for (HashMap.Entry<String,ArrayList<String>> entry : logAfterDate.entrySet()){
            for (String logPath : entry.getValue()) {
                FileUtils.copyFileToDirectory(new File(logPath),new File(path+"Archive\\"+entry.getKey()+"//"));
//                FileUtils.moveFileToDirectory(new File(logPath),new File(path+entry.getKey()+"//"),true);
            }
        }
        ZipUtil.pack(new File(path+"Archive\\"),new File(path+"archive.zip"));
    }
 
开发者ID:asmodeirus,项目名称:BackOffice,代码行数:16,代码来源:LogFilesStructure.java

示例13: copyNewFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * 拷贝源文件夹至目标文件夹
 * 只拷贝新文件 
 * @param sourceFolder
 * @param targetFolder
 */
public static void copyNewFile(String sourceFolder, String targetFolder){
	try{
		File sourceF = new File(sourceFolder);
		
		if(!targetFolder.endsWith("/")) targetFolder=targetFolder+"/";
	 
		if (sourceF.exists()){
			File[] filelist = sourceF.listFiles();
			for(File f:filelist){
				File targetFile = new File(targetFolder+f.getName());
				
				if(  f.isFile()){
					 //如果目标文件比较新,或源文件比较新,则拷贝,否则跳过
					if(!targetFile.exists() || FileUtils.isFileNewer(f, targetFile)){
						FileUtils.copyFileToDirectory(f, new File(targetFolder));
						////System.out.println("copy "+ f.getName());
					}else{
					//	//System.out.println("skip  "+ f.getName());
					}
				}
			}
		}
	 
	 
	}catch(Exception e){
		e.printStackTrace();
		throw new RuntimeException("copy file error");
	}
}
 
开发者ID:yulele166,项目名称:pub-service,代码行数:36,代码来源:FileUtil.java

示例14: copyFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void copyFile(String source, String destination) {
    if (source != null && source.trim().length() > 0 && destination != null && destination.trim().length() > 0) {
        File sourceFile = new File(source);
        File destFile = new File(destination);
        try {
            if (!destFile.exists()) {
                destFile.mkdirs();
            }
            FileUtils.copyFileToDirectory(sourceFile, destFile);
        } catch (IOException ex) {
            Logger.getLogger(FileOptions.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:15,代码来源:FileOptions.java

示例15: createLogger

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
protected Logger createLogger() throws IOException {
  // create configuration with log-file and log-level
  this.configDirectory = new File(getUniqueName());
  this.configDirectory.mkdir();
  assertTrue(this.configDirectory.isDirectory() && this.configDirectory.canWrite());

  // copy the log4j2-test.xml to the configDirectory
  // final URL srcURL =
  // getClass().getResource("/org/apache/geode/internal/logging/log4j/log4j2-test.xml");
  final URL srcURL = getClass().getResource("log4j2-test.xml");
  final File src = new File(srcURL.getFile());
  FileUtils.copyFileToDirectory(src, this.configDirectory);
  this.config = new File(this.configDirectory, "log4j2-test.xml");
  assertTrue(this.config.exists());

  this.logFile = new File(this.configDirectory, DistributionConfig.GEMFIRE_PREFIX + "log");
  final String logFilePath = IOUtils.tryGetCanonicalPathElseGetAbsolutePath(logFile);
  final String logFileName = FileUtil.stripOffExtension(logFilePath);
  setPropertySubstitutionValues(logFileName, DEFAULT_LOG_FILE_SIZE_LIMIT,
      DEFAULT_LOG_FILE_COUNT_LIMIT);

  final String configPath =
      "file://" + IOUtils.tryGetCanonicalPathElseGetAbsolutePath(this.config);
  System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configPath);

  final Logger logger = LogManager.getLogger();
  return logger;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:29,代码来源:Log4J2PerformanceTest.java


注:本文中的org.apache.commons.io.FileUtils.copyFileToDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。