import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
public class TakeFilePathAndName {
public static void main(String[] args) throws FileNotFoundException{
// This is the path where the file's name you want to take.
String path = "D:\\10stanford 100";
File file = new File(path);
File[] array = file.listFiles();
String s = null;
for(int i =0;i< array.length;i++) {
try {
s = "d:\\stanford\\"+array[i].getName()+".txt";
File file1 = new File(s);
file1.createNewFile();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
getFile(array[i].getPath(),s); //得到根目录下的文件路径
}
}
private static void getFile(String path,String s) {
//
读取文件夹下的子文件夹的所有文件名,并保存成以子文件命名的txt文件
最新推荐文章于 2022-12-28 15:02:44 发布