python:
# 获取所有txt路径列表 file_list = [] def gci(filepath): files=os.listdir(filepath) for fi in files: fi_d=os.path.join(filepath,fi) if os.path.isdir(fi_d): gci(fi_d) else: file_list.append(os.path.join(filepath,fi_d)) gci('E:\data')
java:
public static void refreshFileList(String strPath) { File dir = new File(strPath); File[] files = dir.listFiles(); if (files == null) return; for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { refreshFileList(files[i].getAbsolutePath()); } else { String strFileName = files[i].getAbsolutePath().toLowerCase(); filelist.add(files[i].getAbsolutePath()); } } }