本文整理汇总了Java中org.apache.commons.io.FileUtils.moveFileToDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.moveFileToDirectory方法的具体用法?Java FileUtils.moveFileToDirectory怎么用?Java FileUtils.moveFileToDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileUtils
的用法示例。
在下文中一共展示了FileUtils.moveFileToDirectory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeAvroSchema
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void writeAvroSchema(final Schema schema) throws IOException {
// Generate schema in JAR output directory.
final File schemaFile = new File(options.getJarOutputDir(), schema.getName() + ".avsc");
LOG.info("Writing Avro schema file: " + schemaFile);
FileUtils.forceMkdir(schemaFile.getParentFile());
FileUtils.writeStringToFile(schemaFile, schema.toString(true));
// Copy schema to code output directory.
try {
FileUtils.moveFileToDirectory(schemaFile, new File(options.getCodeOutputDir()), true);
} catch (final IOException e) {
LOG.debug("Could not move Avro schema file to code output directory.", e);
}
}
示例2: moveToDirectory
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void moveToDirectory(File target) {
if (target.exists() && !target.isDirectory()) {
throw new RuntimeException(String.format("Target '%s' is not a directory", target));
}
try {
FileUtils.moveFileToDirectory(this, target, true);
} catch (IOException e) {
throw new RuntimeException(String.format("Could not move test file '%s' to directory '%s'", this, target), e);
}
}
示例3: moveProduct
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* Moves product download zip into the given destination.
* <p><b>Note:</b> generates the zip of product if necessary.</p>
*
* @param product product to move.
* @param destination destination of product
*/
private void moveProduct (Product product, String destination)
{
if (destination == null || destination.trim ().isEmpty ())
{
return;
}
Path zip_destination = Paths.get (destination);
String download_path = product.getDownloadablePath ();
try
{
if (download_path != null)
{
File product_zip_file = Paths.get (download_path).toFile ();
FileUtils.moveFileToDirectory (
product_zip_file, zip_destination.toFile (), true);
}
else
{
Path product_path = Paths.get (product.getPath ().getPath ());
if (UnZip.supported (product_path.toAbsolutePath ().toString ()))
{
FileUtils.moveFileToDirectory (
product_path.toFile (), zip_destination.toFile (), true);
}
else
{
zip_destination.resolve (product_path.getFileName ());
generateZip (product_path.toFile (), zip_destination.toFile ());
}
}
}
catch (IOException e)
{
LOGGER.error("Cannot move product: " + product.getPath () +
" into " + destination, e);
}
}
示例4: move
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@ProtoMethod(description = "Move a file to a directory", example = "")
@ProtoMethodParam(params = {"name", "destination"})
public void move(String name, String to) {
File fromFile = new File(getAppRunner().getProject().getFullPathForFile(name));
File dir = new File(getAppRunner().getProject().getFullPathForFile(to));
dir.mkdirs();
try {
FileUtils.moveFileToDirectory(fromFile, dir, false);
} catch (IOException e) {
e.printStackTrace();
}
}