如何實現文件夾對文件夾的拷貝呢?如果文件夾裡還有文件夾怎麼辦呢?
接下來我就將我的方法演示給一些初學者
/*
* CopyRight by
*/
package copyfile;
import java
/**
* @author Administrator
*
* Class Function:
*/
public class copyDirectory {
public static void main(String args[]) throws IOException {
String url
String url
(new File(url
File[] file=(new File(url
for(int i=
if(file[i]
FileInputStream input=new FileInputStream(file[i]);
FileOutputStream output=new FileOutputStream(url
byte[] b=new byte[
int len;
while((len=input
output
}
output
output
input
}
if(file[i]
copyDirectiory(url
}
}
}
public static void copyDirectiory(String file
(new File(file
File[] file=(new File(file
for(int i=
if(file[i]
FileInputStream input=new FileInputStream(file[i]);
FileOutputStream output=new FileOutputStream(file
byte[] b=new byte[
int len;
while((len=input
output
}
output
output
input
}
if(file[i]
copyDirectiory(file
}
}
}
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19270.html