250x250
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
- pbcopy
- 리팩터링
- 1일1커밋
- 가성비 다이버
- eventsourcing
- 떱텐
- html/css 완강
- 다짐
- 재택
- mn나토
- python scrap title
- 시계 줄질
- js이론
- python
- html/css
- 컨테이너 지우기
- Docker
- 클론코딩
- 전체지우기
- python flask
- 주우재시계
- 야근
- 5600B
- 손목난민
- github
- sne573
- CSS
- 코더가 아닌 개발자
- python scrap
- Git
Archives
- Today
- Total
발전하는 나를 기록하기 위해
ClassLoader 상대경로 파일읽기 본문
728x90
- 경로에 '/' 붙지 않은경우, 클래스가 위치한 패키지 내에 파읽 읽음.
InputStream in = this.getClass().getResourceAsStream("test.txt");
- 경로에 '/' 붙은 경우, ClassLoader의 모든 경로에서 파일 읽음. 보통 src/main/resources 폴더의 파일 읽을때 사용.
InputStream in = this.getClass().getResourceAsStream("/test.txt");
- 경로에 '/' 붙지않음. ClassLoader의 모든 경로에서 파일 읽음. 보통 src/main/resources 폴더의 파일 읽을때 사용.
InputStream in = this.getClass().getClassLoader().getResourceAsStream("test.txt");
- ClassLoader의 Class내에 파일존재하는 경우
InputStream in = this.getClass().getResourceAsStream("/com/test/controller/test.txt");
// 경로에 '/' 붙은 경우, ClassLoader의 모든 경로에서 파일 읽음.
InputStream in = this.getClass().getClassLoader().getResourceAsStream("com/test/controller/test.txt");
// 경로에 '/' 붙지않음. ClassLoader의 모든 경로에서 파일 읽음.
'개발 > Java' 카테고리의 다른 글
| java stream (0) | 2024.03.14 |
|---|---|
| Association(연관), Aggregation(집합), Composition(구성) (0) | 2024.03.05 |