String url1 = "F:\\SuperMap-Projects\\region.udb";// 源文件路径 try {
for(int i=1;i<101;i++){
String url2 = "F:\\SuperMap-Projects\\region"+i+".udb";// 目标路径(复制到E盘,重命名为b.txt)
copy(url1, url2);
} } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} private static void copy(String url1, String url2) throws Exception {
FileInputStream in = new FileInputStream(new File(url1));
FileOutputStream out = new FileOutputStream(new File(url2));
byte[] buff = new byte[512];
int n = 0;
System.out.println("复制文件:" + "\n" + "源路径:" + url1 + "\n" + "目标路径:"
+ url2);
while ((n = in.read(buff)) != -1) {
out.write(buff, 0, n);
}
out.flush();
in.close();
out.close();
System.out.println("复制完成");
}