Skip to content

Commit cf43f20

Browse files
committed
Added to read file which is located inside a JAR file
- JAR 안에서 파일을 읽어야 할때
1 parent a4e8537 commit cf43f20

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

jar_resource.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Jar 파일에서 resources 파일 접근할때
2+
- 로컬에서 하면 File이나 InputStream이나 별차이가 없다.
3+
- 근데 `jar`로 말고나서는 차이가 난다.
4+
5+
```java
6+
File test = new File(Test.class.getResource("/test.json").getFile()); // 못 불러옴
7+
InputStream is = Test.class.getResourceAsStream("/test.json"); // 불러옴
8+
```

0 commit comments

Comments
 (0)