public static void main(String[] args) throws IOException {
File f1 = new File("E:\\java2345");
File f2 = new File("G:\\");
copy(f1,f2);
}
public static void copy(File f1,File f2) throws IOException {
if(f1==null)
return;
String[] filenames = f1.list();
for(String filename : filenames)
File fl1 = new File(f1,filename);------------------------->这句提示出错....纠结,实在想不通哪里错了
File fl2 = new File(f2,f1.getName());
if(f1.isDirectory()) {
f2.mkdir();
copy(f1,fl2);
}
else {
copyFile(f1, fl2);
}
}
public static void copyFile(File f1, File f2) {
InputStream in = null;
OutputStream out = null;
try {
in = new FileInputStream(f1);
out = new FileOutputStream(f2);
readAndwriter(in, out);
}
catch(IOException e ) {
e.printStackTrace();
}
finally {
ioClose(in, out);
}
}
private static void readAndwriter(InputStream in, OutputStream out)
throws IOException {
byte[] byts = new byte[1024];
public static void main(String[] args) throws IOException {
File f1 = new File("D:\\ppppppppppppppp");
File f2 = new File("D:\\o");
copy(f1, f2);
}
public static void copy(File f1, File f2) throws IOException {
if (f1 == null)
return;
String[] filenames = f1.list();
for (int i = 0; i < filenames.length; i++) {
System.out.println(filenames);
File fl1 = new File(f1, filenames);
// ------------------------->这句提示出错....纠结,实在想不通哪里错了
public static void main(String[] args) throws IOException {
File f1 = new File("D:\\ppppppppppppppp");
File f2 = new File("D:\\o");
copy(f1, f2);
}
public static void copy(File f1, File f2) throws IOException {
if (f1 == null)
return;
String[] filenames = f1.list();
for (int i = 0; i < filenames.length; i++) {
System.out.println(filenames);
File fl1 = new File(f1, filenames);
// ------------------------->这句提示出错....纠结,实在想不通哪里错了