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 | 31 |
Tags
- java#왕초보
- 코틀린
- 답글
- snowpack
- 숫자
- Android
- git
- 스타일보험
- java
- 스프링
- webpack
- FIle
- 게시판
- 왕초보
- Spring
- Spinner
- 오버라이드
- 안드로이드
- kotlin
- React
- 쿠키
- 시큐어코딩
- 함수
- degit
- 버전일치
- 상속
- SQL
- 미니게임
- parcel
- sub query
Archives
- Today
- Total
YSHUSH
File I/O 본문
˙ IO == Input & Output의 약자
File : 저장 매체
Database(file) - 데이터베이스도 파일입출력이다.
// 파일? 폴더? 조사
/*
File filelist[] = file.listFiles();
for (int i = 0; i < filelist.length; i++) {
if(filelist[i].isFile()) { // if(filelist[i].isFile() == true) 원래는 이런식으로 써야됨
System.out.println("[파일]" + filelist[i].getName());
}
else if(filelist[i].isDirectory()) { // Directory == 폴더
System.out.println("[폴더]" + filelist[i].getName());
}
}
// file, isFile등은 기능부분으로, 알아두면 편리함!
*/
// 파일 생성
File newFile = new File("d:\\myfile\\newfile.txt");
try {
if (newFile.createNewFile()) {
System.out.println("파일 생성 성공!");
} else {
System.out.println("파일 생성 실패!");
}
} catch (IOException e) {
System.out.println("파일을 생성하지 못했습니다.");
}
// 폴더 생성(디렉토리)
File newDir = new File("d:\\myfile\\myimage");
if(newDir.mkdir()) {
System.out.println("폴더 생성 성공!");
} else {
System.out.println("폴더 생성 실패!");
}
// file 존재 여부
if(newFile.exists()) {
System.out.println("newfile.txt가 존재합니다");
} else {
System.out.println("newfile.txt가 존재하지 않습니다");
}
// 읽기전용(보안식) - 고치지 못하게
// newFile.setReadOnly();
// 쓰기 가능 여부
if(newFile.canWrite()) {
System.out.println("쓰기 가능합니다");
} else {
System.out.println("쓰기 불가능합니다");
}
// 파일 삭제
// newFile.delete();
'Coding > Java' 카테고리의 다른 글
File writer (0) | 2021.12.14 |
---|---|
File reader (0) | 2021.12.14 |
Exception (0) | 2021.12.14 |
Overload (0) | 2021.12.14 |
Method1 (0) | 2021.12.12 |