public class FileNumber
{
public static void main(String[] argv)
{
String C = "C:\\Users"; 檔案路徑, 兩個\\是做跳脫字元用
StringBuffer fileList = new StringBuffer();
try{
java.io.File folder = new java.io.File(C);
String[] list = folder.list();
for(int i = 0; i < list.length; i++){
fileList.append(list[i]).append(", ");
}
}catch(Exception e){
System.out.println("'"+C+"'Not found");
}
System.out.println(fileList);
}
}
參考: http://blog.udn.com/LupinBlog/1936404
沒有留言:
張貼留言