关于文件属性(Java)
1、编写一个程序,指定一个文件夹,能自动计算出其总容量 import java.io.File; import java.util.ArrayList; public class FileAction { ArrayList<File> fileList; File root; public FileAction(String pathName) { root = new File(pathName); fileList = new ArrayList<>(); } public void searchFiles() { File[] files = root.listFiles(); int length = files.length; for (int i = 0; i < length; i++) { if (files[i].isDirectory()) { root = files[i]; searchFiles(); } else { fileList.add(files[i]); } } } public void countFiles() { long totalSize = 0; System.out.println("文件数:" + fileList.size()); for (int i = 0; i < fileList.size(); i++) {