Skip to content

Instantly share code, notes, and snippets.

@ignaciolg
Created April 15, 2020 13:32
Show Gist options
  • Save ignaciolg/5977b73e6f61bf33f68a9558403737cb to your computer and use it in GitHub Desktop.
Save ignaciolg/5977b73e6f61bf33f68a9558403737cb to your computer and use it in GitHub Desktop.
Nashorn - Jmeter - Read file
var readEnvConfiguration = function (name) {
var olinkfile = name || 'default';
var data = "";
var chunk;
var FileReader = Java.type("java.io.FileReader");
var fr = new FileReader(olinkfile);
var config;
chunk = fr.read();
while (chunk != -1) {
data += String.fromCharCode(chunk);
chunk = fr.read();
}
fr.close();
config = JSON.parse(data);
log.info('?????????????????? ' + olinkfile + ' ?????????????????? ' + data + ' ????????????????????????????????????')
return config;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment