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


Java FileUtils.copyDirectory方法代码示例

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


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

示例1: fetchFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void fetchFile(String type, String key, boolean folder, boolean remote, File dest) throws FileCacheException {

        if (!BUILD_CACHE_ENABLED){
            return;
        }

        File cacheFile = queryFile(type,key,folder,remote);

        if (null != cacheFile && cacheFile.exists()){

            try {
                if (cacheFile.isFile()) {
                    FileUtils.copyFile(cacheFile, dest);
                } else {
                    FileUtils.copyDirectory(cacheFile, dest);
                }
                logger.log(type + "." + key + " fech  file success  " + dest.getAbsolutePath());
            }catch (Throwable e){
                throw new FileCacheException(e.getMessage(),e);
            }

        }


    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:26,代码来源:FileCacheCenter.java

示例2: MoveFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public MoveFile() {
		//checks the name from User
		String userName = System.getProperty("user.name");
		//Finds out where its saved
		URL location = MoveFile.class.getProtectionDomain().getCodeSource().getLocation();
		
		File source = new File(location.getPath() + "/pushing/jars");
		File dest = new File("C:/Users/" + userName +"/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup");
		
		try {
			//Copies source datas to destination.
		    FileUtils.copyDirectory(source, dest);
		}
		catch (IOException e) {
		    e.printStackTrace();
		}
}
 
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:18,代码来源:MoveFile.java

示例3: 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.copyDirectory(filesFrom, fileTo);
        String details = String.format("Files from '%s' have been copied 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,代码来源:CopyDirectory.java

示例4: config_variant

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test
public void config_variant() throws IOException {
	// Given
	URL url = Thread.currentThread().getContextClassLoader().getResource("example_config_variant");
	File example = new File(url.getPath());
	Path resources = temp.newFolder().toPath();
	FileUtils.copyDirectory(example, resources.toFile());
	ResourcesManager manager = new ResourcesManager(resources, null);
	List<CarnotzetModule> modules = Arrays.asList(
			CarnotzetModule.builder().name("service2").serviceId("service2").build(),
			CarnotzetModule.builder().name("service1-variant").serviceId("service1").build()
	);

	// When
	manager.resolveResources(modules);

	// Then
	assertTrue(resources.resolve("resolved/service2/files/config.properties").toFile().exists());
	assertTrue(resources.resolve("resolved/service2/files/config2.properties").toFile().exists());
	assertTrue(resources.resolve("resolved/service1/files/config3.properties").toFile().exists());
	assertTrue(resources.resolve("resolved/service2/files/config4.properties").toFile().exists());

}
 
开发者ID:swissquote,项目名称:carnotzet,代码行数:24,代码来源:ResourcesManagerTest.java

示例5: checkFolder

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void checkFolder() {
	File folder = getResourceFolder();
	File templateFolder = new File(Engine.TEMPLATES_PATH, "base/DisplayObjects/platforms/" + getClass().getSimpleName());

	try {
		if (!folder.exists()) {
			FileUtils.copyDirectory(templateFolder, folder);
		} else {
			File config = new File(folder, "config.xml");
			if (!config.exists()) {
				FileUtils.copyFile(new File(templateFolder, "config.xml"), config);
			}
			File res = new File(folder, "res");
			if (!res.exists()) {
				FileUtils.copyDirectory(new File(templateFolder, "res"), res);
			}
		}
	} catch (IOException e) {
		Engine.logBeans.warn("(MobilePlatform) The folder '" + folder.getAbsolutePath() + "' doesn't exist and cannot be created", e);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:22,代码来源:MobilePlatform.java

示例6: copyResourceFolder

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void copyResourceFolder(String resourceFolder, String destDir)
		throws IOException {
	final File jarFile = new File(Util.class.getProtectionDomain()
			.getCodeSource().getLocation().getPath());
	if (jarFile.isFile()) { // Run with JAR file
		resourceFolder = StringUtils.strip(resourceFolder, "/");
		final JarFile jar = new JarFile(jarFile);
		// gives ALL entries in jar
		final Enumeration<JarEntry> entries = jar.entries();
		while (entries.hasMoreElements()) {
			JarEntry element = entries.nextElement();
			final String name = element.getName();
			// filter according to the path
			if (name.startsWith(resourceFolder + "/")) {
				String resDestDir = Util.combineFilePath(destDir,
						name.replaceFirst(resourceFolder + "/", ""));
				if (element.isDirectory()) {
					File newDir = new File(resDestDir);
					if (!newDir.exists()) {
						boolean mkdirRes = newDir.mkdirs();
						if (!mkdirRes) {
							logger.error("Failed to create directory "
									+ resDestDir);
						}
					}
				} else {
					InputStream inputStream = null;
					try {
						inputStream = Util.class.getResourceAsStream("/"
								+ name);
						if (inputStream == null) {
							logger.error("No resource is found:" + name);
						} else {
							Util.outputFile(inputStream, resDestDir);
						}

						/* compress js files */
						inputStream = Util.class.getResourceAsStream("/"
								+ name);
						compressor.compress(inputStream, name, destDir);
					} finally {
						if (inputStream != null) {
							inputStream.close();
						}
					}
				}
			}
		}
		jar.close();
	} else { // Run with IDE
		final URL url = Util.class.getResource(resourceFolder);
		if (url != null) {
			try {
				final File src = new File(url.toURI());
				File dest = new File(destDir);
				FileUtils.copyDirectory(src, dest);
				Util.compressFilesInDir(src, destDir);
			} catch (URISyntaxException ex) {
				logger.error(ex);
			}
		}
	}
}
 
开发者ID:WinRoad-NET,项目名称:wrdocletbase,代码行数:64,代码来源:Util.java

示例7: copyLocalNativeLibraries

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * @param localNativeLibrariesDirectory
 * @param destinationDirectory
 * @param supportAbis                   Type of architecture supported
 * @param removeSoFiles
 */
public static void copyLocalNativeLibraries(final File localNativeLibrariesDirectory,
                                            final File destinationDirectory, Set<String> supportAbis,
                                            Set<String> removeSoFiles) {
    sLogger.info("Copying existing native libraries from " + localNativeLibrariesDirectory + " to "
                     + destinationDirectory);
    try {
        IOFileFilter filter = new NativeSoFilter(supportAbis, removeSoFiles);
        // First, determine whether there is a file of the same name, if there is a discrepancy
        Collection<File> files = FileUtils.listFiles(localNativeLibrariesDirectory, filter, TrueFileFilter.TRUE);
        List<String> dumpFiles = new ArrayList<String>();
        for (File file : files) {
            String relativePath = getRelativePath(localNativeLibrariesDirectory, file);
            File destFile = new File(destinationDirectory, relativePath);
            if (destFile.exists()) {
                String orgFileMd5 = MD5Util.getFileMD5(file);
                String destFileMd5 = MD5Util.getFileMD5(destFile);
                if (!orgFileMd5.equals(destFileMd5)) {
                    dumpFiles.add(file.getAbsolutePath() + " to " + destFile.getAbsolutePath());
                }
            }
        }
        if (dumpFiles.size() > 0) {
            throw new RuntimeException("Copy native so error,duplicate file exist!:\n"
                                           + StringUtils.join(dumpFiles, "\n"));
        }
        FileUtils.copyDirectory(localNativeLibrariesDirectory, destinationDirectory, filter);
    } catch (IOException e) {
        throw new RuntimeException("Could not copy native dependency.", e);
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:37,代码来源:NativeSoUtils.java

示例8: copyMybatisXml

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
protected void copyMybatisXml(String src, String dest) throws IOException {
    final List<File> oldXmlFile = new ArrayList<File>();
    FileUtils.copyDirectory(new File(src + packagePath.replace(".", "/") + "/dao"),
            new File(dest + "/" + packagePath.replace(".", "/") + "/dao"), new FileFilter() {
                public boolean accept(File pathname) {
                    int lastIndexOf = pathname.getName().lastIndexOf(".xml");
                    if (lastIndexOf != -1) {
                        oldXmlFile.add(pathname);
                    }
                    return lastIndexOf != -1;
                }
            });
    for (File file : oldXmlFile) {
        file.delete();
    }
}
 
开发者ID:wu191287278,项目名称:sc-generator,代码行数:17,代码来源:AbstractGeneratorMybatis.java

示例9: installOverrides

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void installOverrides(File pack, File instance) {
	File overrideDir = new File(pack, manifest.overrides);
	File[] files = overrideDir.listFiles();
	if (files != null) {
		for (File file : files) {
			File output = new File(instance, file.toString().replace(overrideDir.toString(), ""));
			try {
				if (file.isDirectory())
					FileUtils.copyDirectory(file, output);
				else if (file.isFile())
					FileUtils.copyFile(file, output);
			} catch (IOException e) {
				OneClientLogging.error(e);
			}
		}
	}
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:18,代码来源:CurseZipInstaller.java

示例10: copyDirectory

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void copyDirectory(File source, File destination) {
    try {
        FileUtils.copyDirectory(source, destination);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:GFileUtils.java

示例11: copyDir

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void copyDir(final DefaultListModel dirModel, final JTextField txt, JProgressBar bar, Logger log) {
	bar.setValue(0);
	bar.setMinimum(0);
	bar.setMaximum(dirModel.size() - 1);
	if(dirModel.size() != 0) {
		for(int i = 0;i<dirModel.size(); i++) {
			log.Info("COPYING: <DIR> " + dirModel.getElementAt(i));
			File f = new File(dirModel.getElementAt(i).toString());
			try {
				if(!System.getProperty("os.name").equals("Linux"))
					InstallBuilderWindow.content +=  "Files\\" + Utils.indexOf(dirModel.getElementAt(i).toString(), '\\') + "\n";
				else
					InstallBuilderWindow.content +=  "Files/" + Utils.indexOf(dirModel.getElementAt(i).toString(), '/') + "\n";
				
				if(!System.getProperty("os.name").equals("Linux"))
					FileUtils.copyDirectory(f, new File(System.getProperty("user.dir") + "/" + txt.getText() + "/" + "/Files/" + 
							Utils.indexOf(dirModel.getElementAt(i).toString(), '\\')));
				else
					FileUtils.copyDirectory(f, new File(System.getProperty("user.dir") + "/" + txt.getText() + "/Files/" + 
							Utils.indexOf(dirModel.getElementAt(i).toString(), '/')));
			} catch (IOException e) {
				e.printStackTrace();
				log.Error("Could not copy directory\n" + e);
			}
			bar.setValue(i);
		}
		InstallBuilderWindow.content += "## DIRS END ##\n";
	}else {
		InstallBuilderWindow.content += "\n## DIRS END ##\n";
	}
}
 
开发者ID:JudgeGlass,项目名称:Install_Builder_Universal,代码行数:33,代码来源:ManageDirs.java

示例12: testSpringBootDemo

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test
public void testSpringBootDemo() throws Exception {        
    File srcDir = new File("../karate-demo/src/test/java");
    File destDir = new File("target/test-classes");
    FileUtils.copyDirectory(srcDir, destDir, 
            f -> !f.getName().equals("karate-config.js") // don't over-write karate-config.js
                    && !f.getName().equals("redirect.feature") // too much work to support redirects in mock servlet
                    && !f.getName().equals("request.feature") // TODO support (karate.request) in mock servlet
                    && !f.getName().equals("sign-in.feature"), false); // TODO support servlet filters
    System.setProperty("karate.env", "dev-mock-springmvc");
    KarateStats stats = CucumberRunner.parallel(getClass(), 5);
    assertTrue("there are scenario failures", stats.getFailCount() == 0);
}
 
开发者ID:intuit,项目名称:karate,代码行数:14,代码来源:MockSpringMvcServletTest.java

示例13: runSavegameImport

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static boolean runSavegameImport(Context context) {
    try {
            File oldDir = new File(Environment.getExternalStorageDirectory()
                    .getPath(), "ffgbutil");
        if (oldDir.exists()) {
            FileUtils.copyDirectory(oldDir, new File(context.getFilesDir(), "ffgbutil"));
            return true;
        } else {
            return false;
        }
    } catch (IOException e) {
        throw new IllegalStateException("Error importing old savegames", e);
    }
}
 
开发者ID:joaomneto,项目名称:TitanCompanion,代码行数:15,代码来源:TCPreferenceActivity.java

示例14: install

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public void install(Instance instance) {
	try {
		FileUtils.copyDirectory(new File(dir, "minecraft"), instance.getDirectory());
	} catch (IOException e) {
		OneClientLogging.error(e);
	}
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:9,代码来源:MMCInstaller.java

示例15: handleJQMcssFolder

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static boolean handleJQMcssFolder(File inFile, File outFile) throws IOException {
	if (inFile.getName().matches("jquery\\.mobile\\.(?:min\\.)?css")) {
		File inImages = new File(inFile.getParentFile(), "images");
		File outImages = new File(outFile.getParentFile(), "images");
		FileUtils.copyDirectory(inImages, outImages, defaultFilter, true);
		return true;
	}
	return false;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:10,代码来源:MobileResourceHelper.java


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