求高手指点:java.io.FileNotFoundException: D:\晋级\jdbc\01_传智播客JDBC_jdbc的理论概述 (拒绝访问。)
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class IO {
/**
* @需求:把一个文件夹中的子文件考入指定的文件夹中
*/
public static void main(String[] args) {
File fc = new File("D:\\晋级\\jdbc");
String fvs = "D:\\晋级\\jdbc\\all";
copyfile(fc,fvs);
}
static void copyfile(File fc,String fvs) {
FileInputStream fin = null;
FileOutputStream fos = null;
File fv = new File(fvs);
System.out.println("创建文件夹:"+fv.mkdir());
if (fc.isDirectory()) {
File[] fs = fc.listFiles();
for (File f : fs) {
if (f.isDirectory()) {
copyfile(f, fvs);
} else {
try {
String fname = f.getName();
fin = new FileInputStream(fc);
fos = new FileOutputStream(fv+"\\"+fname);
byte[] b = new byte[1024];
int len = 0;
while((len=fin.read(b))!=-1){
fos.write(b, 0, len);
fos.flush();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
//关闭流
if(fin!=null){
try {
fin.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(fos!=null){
try {
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
} else {
System.out.println("不是文件夹");
}
}
}