具体代码如下:
public class FileInfo {
public static void main(String[] args) throws Exception {
getFileInfo("C:/Users/DELL/Desktop/wsdl/");
}
private static void getFileInfo(String filename) throws Exception {
File file = new File(filename);
if (file.isDirectory()) {
File[] list = file.listFiles();
for (int i = 0; i < list.length; i++) {
System.out.println(list[i].getName());
OutputStream out = new FileOutputStream(
"C:/Users/DELL/Desktop/wsdl.txt", true);
byte[] buff = (list[i].getName() + "\r\n").getBytes();
out.write(buff);
out.flush();
}
}
}
}