Guest User

Untitled

a guest
Dec 12th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. root
  2.  
  3. src
  4.  
  5. main
  6.  
  7. resources
  8.  
  9. setup.xml
  10.  
  11. root
  12.  
  13. [...]
  14.  
  15. setup.xml
  16.  
  17. // by path
  18. val filePath = getClass.getResource("/setup.xml").getPath
  19. val currentPath = Paths.get(filePath)
  20. val parsed = XML.loadFile(currentPath.toString)
  21.  
  22. // by URI
  23. val filePath = getClass.getResource("/setup.xml").toURI
  24. val currentPath = Paths.get(filePath)
  25. val parsed = XML.loadFile(currentPath.toString)
  26.  
  27. // with classloader
  28. val filePath = getClass.getClassLoader.getResource("setup.xml").toURI
  29. val currentPath = Paths.get(filePath)
  30. val parsed = XML.loadFile(currentPath.toString)
  31.  
  32. val source = Source.fromURL(getClass.getResource("/setup.xml"))
  33. val parsed = XML.loadString(source.getLines().mkString)
Add Comment
Please, Sign In to add comment