• Post Reply Bookmark Topic Watch Topic
  • New Topic

Relative path issue  RSS feed

 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MyProject package has meterPro.java and this is where I am trying to access Reading.txt file.

Path package has Reading.txt.

Code is



url1 throws nullpointerexception.
 
Shashank Gollapudi
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your text file might not have been in the classpath
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure since there are not enough information.
Anyway, getClassLoader().getResource() searches relative to the classpath root. If you are trying to search relative to .class file, try getClass().getResource(). Not sure but still hope it might help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!