How to get getclass().getResource() from a static context?

前端 未结 5 2057
名媛妹妹
名媛妹妹 2020-12-30 19:14

I have a function where I am trying to load a file to a URL object, because the example project said so.

public class SecureFTP {

    public s         


        
5条回答
  •  余生分开走
    2020-12-30 19:28

    Old question but this hasn't been said yet. You can do this from a static context:

    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    classLoader.getResource("filename");
    

提交回复
热议问题