I want to read xml file in my lift app:
val data = XML.load(new java.io.InputStreamReader(new java.io.FileInputStream(filename), encoding));
However, I am getting java.io.FileNotFoundException
. where should I put the file, and what is the correct path from my scala code?
BTW - I am using embedded jetty for my testing, although I need a solution for dev env and production.
There might be better solution for other paths but there is
var LiftRules.getResource : (String) ⇒ Box[URL]
or
def LiftRules.doWithResource(name: String)(f: (InputStream) ⇒ T): Box[T]
which usually point to files in src/main/resources/
.
There is also
def LiftRules.loadResourceAsXml(name: String): Box[NodeSeq]
which may be the method you are looking for.
To solve this problem in the general case, new File("delme").createNewFile()
and see where it ends up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With