本文整理匯總了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();
}
}