How getClassLoader().getResourceAsStream() works in java

后端 未结 3 1733
天命终不由人
天命终不由人 2020-12-10 17:51

I google how below code loads the resource Abc.class.getClassLoader().getResourceAsStream(\"abc.txt\")
and find that it searchs the resource in all jar file and zip

3条回答
  •  孤城傲影
    2020-12-10 18:36

    For example, you can make a "resources" source folder, put files in it, then use Thread.currentThread().getContextClassLoader().getResourceAsStream("abc.txt");
    I always use this method.

提交回复
热议问题