java实现将指定文件夹里所有文件路径输出到指定文件作为参数化文件给lr脚本使用

时间:2022-01-24 13:07:51

java实现将指定文件夹里所有文件路径输出到指定文件作为参数化文件给lr脚本使用

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter; public class GetFileName { public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in ));
//java.io.InputStreamReader继承了Reader类
String read = null;
System.out.print("输入文件夹:");
read = br.readLine(); BufferedReader br01 = new BufferedReader(new InputStreamReader(System.in ));
//java.io.InputStreamReader继承了Reader类
System.out.print("输出的文件:");
String write = br.readLine(); FileOutputStream fos = new FileOutputStream(write);
OutputStreamWriter osw = new OutputStreamWriter(fos);
BufferedWriter bw = new BufferedWriter(osw); File f = new File(read);
String dir = f.getAbsolutePath();
if(f.isDirectory())
{
String[] ss = f.list();
for(String s:ss)
{
bw.write(dir+"\\"+s);
bw.newLine();
}
}
bw.flush();
bw.close();
}
}