/** |
* |
* 拷贝文件夹中的所有文件到另外一个文件夹 |
* |
* @param srcDirector |
* 源文件夹 |
* |
* @param desDirector |
* 目标文件夹 |
* |
*/ |
public static void copyFileWithDirector(String srcDirector, |
String desDirector) throws IOException { |
( new File(desDirector)).mkdirs(); |
File[] file = ( new File(srcDirector)).listFiles(); |
for ( int i = 0 ; i < file.length; i++) { |
if (file[i].isFile()) { |
log.debug( "拷贝:" + file[i].getAbsolutePath() + "-->" |
+ desDirector + "/" + file[i].getName()); |
FileInputStream input = new FileInputStream(file[i]); |
FileOutputStream output = new FileOutputStream(desDirector |
+ "/" + file[i].getName()); |
byte [] b = new byte [ 1024 * 5 ]; |
int len; |
while ((len = input.read(b)) != - 1 ) { |
output.write(b, 0 , len); |
} |
output.flush(); |
output.close(); |
input.close(); |
} |
if (file[i].isDirectory()) { |
log.debug( "拷贝:" + file[i].getAbsolutePath() + "-->" |
+ desDirector + "/" + file[i].getName()); |
copyFileWithDirector(srcDirector + "/" + file[i].getName(), |
desDirector + "/" + file[i].getName()); |
} |
} |
} |