Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Java
- Graphic
- JSP
- 메서드
- JavaScript
- Android
- 메소드
- 오버로딩
- 배열
- paint
- 생성자
- HTML
- 국제화
- struts2
- 클래스
- mybatis
- 안드로이드
- 예외처리
- Menu
- Spring
- OGNL
- 전화걸기
- layout
- Eclips
- AWT
- 에러페이지
- 기본
- oracle
- 어노테이션
- 이클립스
Archives
- Today
- Total
note
FileEx4 본문
package com.file;//
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class FileEx4 {
public static void main(String[] args) {
String currDir = System.getProperty("user.dir");
File dir = new File(currDir);
File[] files = dir.listFiles();
for(int i=0; i< files.length;i++){
File f= files[i];
String name = f.getName();//디렉토리명 또는 파일명
SimpleDateFormat df =new SimpleDateFormat("yyyy-MM-DD HH:mma");
String attribute = "";
String size="";
if(files[i].isDirectory()){
attribute = "DIR";
}else{
size = f.length()+""; //형변환 long -> String
attribute = f.canRead() ? "R" : " ";
attribute = f.canWrite() ? "W" : " ";
attribute = f.isHidden() ? "H" : " ";
}
System.out.printf("%s %3s %6s %s\n",df.format(new Date(f.lastModified())),attribute,size,name);
}
}
}
'자바 > 입출력' 카테고리의 다른 글
직렬화 (0) | 2012.01.03 |
---|---|
File 생성 및 변경 (2) | 2012.01.02 |
디렉토리 정보 (0) | 2012.01.02 |
입출력으로 파일 상세정보 (0) | 2012.01.02 |
키보드에서 입력받은 내용을 파일에 기록하기 (0) | 2012.01.02 |