public static void main(String[] args) throws IOException

{

File file = new File("C:\\");

String[] filenames;

String fullpath = file.getAbsolutePath(); // 取得路徑

 

if (file.isDirectory())

{

filenames = file.list();

for (int i = 0; i < filenames.length; i++)

{

 

File tempFile = new File(fullpath + "\\" + filenames[i]);

if (tempFile.isDirectory())

{

System.out.println("目錄:" + filenames[i]);

}

else

System.out.println("檔案:" + filenames[i]);

}

}

else

System.out.println("[" + file + "]不是目錄");

}

 

 

by ting

 

 

創作者介紹
創作者 cycu98的部落格 的頭像
cycu98

cycu98的部落格

cycu98 發表在 痞客邦 留言(0) 人氣( 2622 )