Is it possible to read text files from controller scripts?

Post Reply New Topic
RELATED
PRODUCTS

Post

Hi All,

I'm trying to read a simple .txt file from within my controller script, does anyone know if / how
this is possible?
There are all kinds of ways of reading files in Javascript but they all seem to be possible only within webbrowsers. Javascript is not my primary language so I'm kind of new to this and cannot find a
solution.

Cheers,

whizzl

Post

yes, here's one way to do it:

Code: Select all

var filename = "test.txt";
var content = new java.lang.String(
                    java.nio.file.Files.readAllBytes(
                      java.nio.file.Paths.get(filename)
                    )
                  );
println(content);
"test.txt" would then be in your home-directory
source: https://apimeister.com/2015/06/12/read- ... n-jjs.html

Post

post deleted. decided to make this a separate thread.

Post Reply

Return to “Controller Scripting”