遍历问题 你干脆问JAVA能不能定义变量算了,ASP的FOS算什么,JAVA的IO操作更强大,如果连这都不可以,&^76*^&%^$%$#*^ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ......public void bianLi(File f){File lf[]=f.listFile();int i=0;while(i<lf.length){if(lf[i].isDirectory()) bianLi(lf[i])else....do something with lf[i]i++;}} import java.io.*;public class Application3 { boolean packFrame = false; public Application3() { copyDir(new File("c:/temp/"),new File("d:/temp/")); } public void copyDir(File src_path,File dest_path){ if(!dest_path.exists()) dest_path.mkdirs(); File[] files = src_path.listFiles(); for(int i=0;i<files.length;i++){ File src=files[i]; File dest=new File(dest_path.getPath()+File.separator+files[i].getName()); if(!src.isDirectory()) copyFile(src,dest); else copyDir(src,dest); } } public void copyFile(File src,File dest){ try{ System.out.println(src.getAbsoluteFile()+" -> "+dest.getAbsoluteFile()); FileInputStream in = new FileInputStream(src); FileOutputStream out = new FileOutputStream(dest); byte[] buffer = new byte[1024]; int length = -1; while((length=in.read(buffer))!=-1){ out.write(buffer,0,length); } out.flush(); out.close(); in.close(); System.out.println("文件复制成功!"); }catch(Exception e){ System.out.println("文件复制失败!"); } } public static void main(String[] args) { new Application3(); }} FT..........java.io.* 是干嘛用的? 可以自己用深度或广度进行遍历,我自己用vc设计的但算法是一样的,可以进行森林遍历,要的话请来信,Email:[email protected] 楼主被ASP弄蒙了,JAVA可比ASP强多了。java.io.* 是JAVA中专门用来处理输入输出的包。建议楼主查一下java.io.File的JAVA DOC文档就知道了,楼主想做的东西都可以实现 类似百度文库的文件查看问题 四个月学JAVA够了吗?(能够找到工作的程度) operator == cannot be applied to java.lang.String,char 没分了也请帮我看看,谢谢! 菜鸟代码-中文乱码,请高手指点。 我的数据库中数据表明明存在,可是JSP老是说表“XXX”不存在,请问。。。 JadoNet请过来 xml-xsl参数请求 @Override问题,请教 forward和Sendredirect那个跳转是Request不断 初学者请教。 简单问题!
public void bianLi(File f){
File lf[]=f.listFile();
int i=0;
while(i<lf.length){
if(lf[i].isDirectory()) bianLi(lf[i])
else
....do something with lf[i]
i++;
}
}
boolean packFrame = false; public Application3() {
copyDir(new File("c:/temp/"),new File("d:/temp/"));
} public void copyDir(File src_path,File dest_path){
if(!dest_path.exists())
dest_path.mkdirs();
File[] files = src_path.listFiles();
for(int i=0;i<files.length;i++){
File src=files[i];
File dest=new File(dest_path.getPath()+File.separator+files[i].getName());
if(!src.isDirectory())
copyFile(src,dest);
else
copyDir(src,dest);
}
} public void copyFile(File src,File dest){
try{
System.out.println(src.getAbsoluteFile()+" -> "+dest.getAbsoluteFile());
FileInputStream in = new FileInputStream(src);
FileOutputStream out = new FileOutputStream(dest);
byte[] buffer = new byte[1024];
int length = -1;
while((length=in.read(buffer))!=-1){
out.write(buffer,0,length);
}
out.flush();
out.close();
in.close();
System.out.println("文件复制成功!");
}catch(Exception e){
System.out.println("文件复制失败!");
}
} public static void main(String[] args) {
new Application3();
}
}
java.io.* 是JAVA中专门用来处理输入输出的包。
建议楼主查一下java.io.File的JAVA DOC文档就知道了,楼主想做的东西都可以实现