将某盘下所有文件名存在一个文件下面
package com.excelexport.controller;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
public class muluming {
static List<String> ss = new ArrayList<String>();
public static void main(String[] args) throws IOException {
RandomAccessFile des=new RandomAccessFile("D:31.txt", "rw");
File file = new File("D:\\工作目录");
List<String> ss1=search(file);
for(String ss2:ss1) {
des.writeUTF(ss2);
}
}
public static List<String> search(File dir) {
File[] files = dir.listFiles();
for (File file : files) {
if (file.isDirectory()) {
search(file);
} else {
ss.add(file.getName());
}
}
return ss;
}
}