close

We can use File class to open a folder and read the file name of this folder.

and the method , list() , will return an array of strings naming the files in the directory.

 

File dir = new File("folder name");

String[] children = dir.list();

if (children ==null)

{

System.out.println("There is no file in this directory");

}

else

{

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

{

System.out.println(children[i]);

}

}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JerryCheng 的頭像
    JerryCheng

    KwCheng's blog

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