java.nio.file.Path for a classpath resource

后端 未结 8 985
自闭症患者
自闭症患者 2020-11-28 02:55

Is there an API to get a classpath resource (e.g. what I\'d get from Class.getResource(String)) as a java.nio.file.Path? Ideally, I\'d like to use the fancy new Path<

8条回答
  •  难免孤独
    2020-11-28 03:29

    This one works for me:

    return Paths.get(ClassLoader.getSystemResource(resourceName).toURI());
    

提交回复
热议问题