问题描述
解决方案
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
public class TestIO
{
public static void main(String[] args)
{
try
{
File source = new File("D:/imagetmp/tp-20101028-00001");
File destinationDir = new File("D:/grid");
String sourceFileName = source.getName();
File destination = new File(destinationDir + File.separator
+ sourceFileName);
if (!destination.exists())
{
destination.mkdirs();
}
File[] files = source.listFiles();
for (File file : files)
{
FileUtils.copyFileToDirectory(file, destination);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
解决方案二:
写的时候,可能有点问题,看看别人怎么做的吧
FILEUTILS 介绍:http://blog.csdn.net/zdnlp/article/details/7827489
FileUtils快速方便拷贝文件:http://joy-zhang.iteye.com/blog/856676
时间: 2024-12-25 23:14:33