I have written Scala program that is reading some data from file.
lazy val vectorOptF2 = Source.fromFile("DataFiles/F2-xopt.txt").getLines().map(_.toDouble). toList
When I execute my code in IntelliJ IDEA IDE, It run successfully. But when I created JAR file
mvn clean packae
and tried to execute JAR file, it throws error stating so such file found.
Exception in thread "main" java.io.FileNotFoundException: DataFiles/F2-xopt.txt (No such file or directory)
I have created ZIP file DataFiles.zip and move it to JAR file
mv DataFiles.zip MyJar.jar
but same was error. How can I read data from files placed inside a folder in JAR file?
- There are multiple files in side Folder DataFiles and have to read some of them based on specified criteria each time program executes.