import java.io.*;
public class FileTest {
 
private StringBuffer sb;
 
private static double sizes;
 
private void recurseFile(String path){  
  
if(path.indexOf("."== -1){  
  
for(File file: new File(path).listFiles()){
   
if(file.isFile()){
    sizes 
+= file.length();
   }
else{
      recurseFile(file.toString());
   }
}
else
   sizes 
= file.length();
  }
       }  
 
public static void main(String args[]){
  String path 
= "c:/windows";
  FileTest ft 
= new FileTest();
  ft.recurseFile(path);
  System.out.println(sizes
/1024);
 }
}

相关文章:

  • 2021-08-15
  • 2022-01-01
  • 2021-05-25
  • 2022-12-23
  • 2022-02-26
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
相关资源
相似解决方案