private static void copy(File src,File dest) throws IOException {
// TODO Auto-generated method stub
File dir = new File(src,dest.getName());
dir.mkdir();//dir.mkdirs();
File[] fis = src.listFiles();
for (File file : fis) {
if(file.isFile()){
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));//-----------------
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir,src.getName()))));
String line ;
while((line = br.readLine())!=null){
bw.write(line);
}
bw.close();
br.close();
}else{
copy(file,dir);
}
}
} |
|