티스토리 뷰

java,web study/4주차 (7월 22일~28일)

FileInfo

doublemetal 2013. 7. 22. 22:06

import java.io.File;


public class FileInfo {


public static void main(String[] args) {

// TODO Auto-generated method stub

String str = "";


File file = new File("F:\\TreeMapEx1.txt");


if (file.exists()) {

// F:\\TreeMapEx1.txt 파일이 존재하는 경우

str += "파일명:" + file.getName() + "\n" + "파일의 크기:" + file.length()

+ "\n" + "마지막 수정일:" + file.lastModified() + "\n"

+ "부모 디렉토리:" + file.getParent();

} else {

str = "해당 파일이 존재하지 않습니다.";

}

System.out.println(str);

System.out.println("===============");


File dir = new File("."); // 현재 폴더 참조

String[] strs = dir.list(); // 폴더 내의 리스트 반환


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

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

}

}

}



'java,web study > 4주차 (7월 22일~28일)' 카테고리의 다른 글

FileCopy  (0) 2013.07.22
FileDelete  (0) 2013.07.22
DataIOTest  (0) 2013.07.22
RandomFileTest  (0) 2013.07.22
BufferReader  (0) 2013.07.22
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함