本文整理了Java中io.fabric8.utils.Files.copy()
方法的一些代码示例,展示了Files.copy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.copy()
方法的具体详情如下:
包路径:io.fabric8.utils.Files
类名称:Files
方法名:copy
[英]Copy the source File to the target File.
[中]
代码示例来源:origin: io.fabric8/fabric-utils
/**
* Copy the source {@link File} to the target {@link File}.
*/
public static void copy(File source, File target) throws IOException {
if (!source.exists()) {
throw new FileNotFoundException("Source file not found:" + source.getAbsolutePath());
}
if (!target.exists() && !target.getParentFile().exists() && !target.getParentFile().mkdirs()) {
throw new IOException("Can't create target directory:" + target.getParentFile().getAbsolutePath());
}
FileInputStream is = new FileInputStream(source);
FileOutputStream os = new FileOutputStream(target);
copy(is, os);
}
代码示例来源:origin: io.fabric8/fabric8-maven-enricher-fabric8
/**
* Copies any local configuration files into the app directory
*/
private void copyAppConfigFiles(File appBuildDir, File appConfigDir) throws IOException {
File[] files = appConfigDir.listFiles();
if (files != null) {
appBuildDir.mkdirs();
for (File file : files) {
File outFile = new File(appBuildDir, file.getName());
if (file.isDirectory()) {
copyAppConfigFiles(outFile, file);
} else {
Files.copy(file, outFile);
}
}
}
}
代码示例来源:origin: io.fabric8.forge/utils
/**
* Copy the source {@link File} to the target {@link File}.
*
* // TODO DELETEME when fabric8-utils released with this method
*/
public static void copy(File source, File target) throws IOException {
if (!source.exists()) {
throw new FileNotFoundException("Source file not found:" + source.getAbsolutePath());
}
if (!target.exists() && !target.getParentFile().exists() && !target.getParentFile().mkdirs()) {
throw new IOException("Can't create target directory:" + target.getParentFile().getAbsolutePath());
}
if (source.isDirectory()) {
target.mkdirs();
File[] files = source.listFiles();
if (files != null) {
for (File child : files) {
copy(child, new File(target, child.getName()));
}
}
} else {
FileInputStream is = new FileInputStream(source);
FileOutputStream os = new FileOutputStream(target);
io.fabric8.utils.Files.copy(is, os);
}
}
}
代码示例来源:origin: fabric8io/ipaas-quickstarts
protected void copyFile(File src, File dest, Replacement replaceFn, boolean isSource) throws IOException {
if (replaceFn != null && isSource) {
String original = IOHelpers.readFully(src);
String escapedContent = original;
if (original.contains("${")) {
String replaced = escapedContent.replaceAll(Pattern.quote("${"), "\\${D}{");
// add Velocity expression at the beginning of the result file.
// Velocity is used by mvn archetype:generate
escapedContent = "#set( $D = '$' )\n" + replaced;
}
if (original.contains("##")) {
String replaced = escapedContent.replaceAll(Pattern.quote("##"), "\\${H}");
// add Velocity expression at the beginning of the result file.
// Velocity is used by mvn archetype:generate
escapedContent = "#set( $H = '##' )\n" + replaced;
}
// do additional replacement
String text = replaceFn.replace(escapedContent);
IOHelpers.writeFully(dest, text);
} else {
if (LOG.isDebugEnabled()) {
LOG.warn("Not a source dir as the extension is {}", Files.getExtension(src.getName()));
}
Files.copy(src, dest);
}
}
代码示例来源:origin: fabric8io/jube
@Override
public void install(InstallContext installContext, ProcessConfig config, String id, File installDir) throws Exception {
File baseDir = ProcessUtils.findInstallDir(installDir);
Set<Map.Entry<String, String>> entries = localPathToURLMap.entrySet();
for (Map.Entry<String, String> entry : entries) {
String localPath = entry.getKey();
String urlText = entry.getValue();
if (Strings.isNotBlank(urlText)) {
URL url = null;
try {
url = new URL(urlText);
} catch (MalformedURLException e) {
LOG.warn("Ignoring invalid URL '" + urlText + "' for overlay resource " + localPath + ". " + e, e);
}
if (url != null) {
File newFile = new File(baseDir, localPath);
FileChangeInfo changeInfo = installContext.createChangeInfo(newFile);
newFile.getParentFile().mkdirs();
InputStream stream = url.openStream();
if (stream != null) {
Files.copy(stream, new BufferedOutputStream(new FileOutputStream(newFile)));
installContext.onFileWrite(newFile, changeInfo);
}
}
}
}
}
代码示例来源:origin: fabric8io/ipaas-quickstarts
File to = destDir.getCanonicalFile();
LOG.info("Copying git checkout from " + from + " to " + to);
Files.copy(from, to);
代码示例来源:origin: io.fabric8/fabric8-maven-enricher-fabric8
String fileName = "icon." + Files.getFileExtension(iconRef);
File outFile = new File(appBuildDir, fileName);
Files.copy(in, new FileOutputStream(outFile));
log.info("Generated icon file " + outFile + " from icon reference: " + iconRef);
return outFile;
代码示例来源:origin: io.jenkins.updatebot/updatebot-core
configuration.info(LOG, "Adding Jenkinsfile " + Strings.trimAllPrefix(relativePath, "/"));
File dir = context.getDir();
Files.copy(jenkinsfile, new File(dir, "Jenkinsfile"));
return true;
代码示例来源:origin: io.fabric8.updatebot/updatebot-core
configuration.info(LOG, "Adding Jenkinsfile " + Strings.trimAllPrefix(relativePath, "/"));
File dir = context.getDir();
Files.copy(jenkinsfile, new File(dir, "Jenkinsfile"));
return true;
内容来源于网络,如有侵权,请联系作者删除!