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 |
Tags
- Android
- 메서드
- Eclips
- layout
- 생성자
- 배열
- 기본
- 예외처리
- 메소드
- 어노테이션
- OGNL
- 에러페이지
- 국제화
- oracle
- Menu
- 안드로이드
- Spring
- JSP
- Java
- 이클립스
- mybatis
- 클래스
- 오버로딩
- Graphic
- struts2
- 전화걸기
- paint
- HTML
- AWT
- JavaScript
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 |