Java File Processing-traversal folder
I: (1) java does do better in some aspects than c ++. Remember when I used c ++ to traverse all the files in the folder, it took a long time-Baidu's results were provided in different compiling environments. h. The header file is different. I want ...... Poor cross-platform performance!
(2) The encapsulated classes in java are very useful. If you want to view the source code, you only need to download the corresponding src file and wake up the association. Then you can see the internal implementation of the detailed functions.
II. The problem today is that you want to process all the data in a folder. The first step is to obtain the names of all the files in the folder in sequence-this function is available in java.
The following method can also be used. In this way, you can get the name without converting it to the File object File = new file ("D: \"); String test []; test = file. list (); for (int I = 0; I
III. A complete project
Package edu. tju. cs; import java. io. File; import java. util. ArrayList; public class Calculate3Dimensions {private static ArrayList
SubFilePaths = new ArrayList
(); // Subfolder set private static ArrayList
FileList = new ArrayList
(); // The file set public void getAllFiles (String filePath) under this directory {/* the above method is also acceptable, and I can get the name directly, you do not need to convert it to the File object File = new file ("D: \"); String test []; test = File. list (); for (int I = 0; I