java遍历文件夹
privatevoidaaa(){Filef=newFile("c://");String[]m_dir=f.list();for(inti=0;i<m_dir.leng...
private void aaa() {
File f = new File("c://");
String[] m_dir = f.list();
for (int i = 0; i < m_dir.length; i++) {
list1.add(m_dir[i]);
}
}
private void list1MouseClicked(java.awt.event.MouseEvent evt) {}list1中双击后子文件怎么出现在list2中呢 展开
File f = new File("c://");
String[] m_dir = f.list();
for (int i = 0; i < m_dir.length; i++) {
list1.add(m_dir[i]);
}
}
private void list1MouseClicked(java.awt.event.MouseEvent evt) {}list1中双击后子文件怎么出现在list2中呢 展开
1个回答
展开全部
static void ListFilesInDirectory(String path ) {
File file = new File(path);
File[] files = file.listFiles();
for (File fl : files) {
if (fl.isDirectory())
ListFilesInDirectory(fl.toString());
else
System.out.println(fl.getName());
}
}
File file = new File(path);
File[] files = file.listFiles();
for (File fl : files) {
if (fl.isDirectory())
ListFilesInDirectory(fl.toString());
else
System.out.println(fl.getName());
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询