Read directory inside JAR with InputStreamReader

前端 未结 2 1214
难免孤独
难免孤独 2020-12-09 21:20

So, this question has been asked a million times i believed and I\'ve been reading them for a couple of hours and trying several options given by some people but none of the

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 22:15

    For Spring Framework users, have a look at PathMatchingResourcePatternResolver to do something like the following:

    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    Resource[] resources = resolver.getResources("classpath:path/to/resource/*.*");
    
    for (Resource resource : resources) {
        InputStream inStream = resource.getInputStream();
        // Do something with the input stream
    }
    

提交回复
热议问题