Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root
- src
- main
- resources
- setup.xml
- root
- [...]
- setup.xml
- // by path
- val filePath = getClass.getResource("/setup.xml").getPath
- val currentPath = Paths.get(filePath)
- val parsed = XML.loadFile(currentPath.toString)
- // by URI
- val filePath = getClass.getResource("/setup.xml").toURI
- val currentPath = Paths.get(filePath)
- val parsed = XML.loadFile(currentPath.toString)
- // with classloader
- val filePath = getClass.getClassLoader.getResource("setup.xml").toURI
- val currentPath = Paths.get(filePath)
- val parsed = XML.loadFile(currentPath.toString)
- val source = Source.fromURL(getClass.getResource("/setup.xml"))
- val parsed = XML.loadString(source.getLines().mkString)
Add Comment
Please, Sign In to add comment