How to make ScriptEngine to run multiple javascript files?
-
28-04-2021 - |
Question
I have 6 js files and I need to include them all into final script to pass ScriptEngine's eval method.How can I do it? ScriptEngine haven't add() method.I can read them with FileReader and than concatenate those strings but I think there will be a better way.
Solution
You can use the overload eval(Reader)
to avoid having to load scripts into a String
yourself.
OTHER TIPS
You could use one script to call the other 6 scripts.
Example:
function callOtherFunctions() {
functionOne();
functionTwo();
.
.
.
functionSix();
}
Not 100% sure how good that solution will work but it will call all other 6 functions.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow