目錄檔案夾
效果圖
代碼
package dirs;
import java.io.File;
public class Test {
public static void main(String[] args) {
String path = "c:\\dirs"; // 指定要周遊的路徑
File file = new File(path); //建立file對象
File[] files = file.listFiles(); // listFiles方法傳回周遊結果數組
for (File f : files) { // 周遊File[]數組
if (!f.isDirectory()) // 不是檔案夾,則列印
System.out.println(f);
}
}
}