String currentDir = System.getProperty("user.dir");
System.out.println("Current folder "+ currentDir);
Tạo đối tượng là thư mục con "In" của thư mục hiện thời
dirIn = new File(currentDir+File.separator+"In");
Một đối tượng File có phải là thư mục hay không, nếu không thì đối tượng đó trỏ tới một file
System.out.println(dirIn + (dirIn.exists() ? " is":" is not" )+" a directory.")
Duyệt danh sách file của thư mục
// get the list of file in dirIn
File[] dirContent = dirIn.listFiles();
if (dirContent != null){// list the content
for (File file : dirContent){// File objects
// xử lí biến file
}
}
Nguồn : http://thegioiweb.vn/Story/vn/laptrinhweb/laptrinhWeb_JavaScript/2009/7/8470.html
No comments:
Post a Comment