Reading txt file from jar fails but reading image works

前端 未结 1 890
梦如初夏
梦如初夏 2020-12-18 12:29

I have an issue which has been bothering me for days... I checked similar questions but couldn\'t find a solution.

I use NetBeans IDE. I build the project jar file i

相关标签:
1条回答
  • 2020-12-18 12:53

    Looking at the source again closely, try..

    URL url = getClass().getResource("/clock/input.txt"); 
    InputStream name = url.openStream(); 
    

    I recall that the Class::getResourceAsStream variant deals with paths slightly differently than simply Class::getResource - I am sure it should work for the latter one.

    0 讨论(0)
提交回复
热议问题