B4J Question Is there a better way?

Bruce Axtens

Active Member
Licensed User
Is there a better way of selecting and inserting into a TextArea from Nashorn (in the context of my BOLE projects)? Currently, I found the following works:
var FileChooser = Java.type("javafx.stage.FileChooser");
var File = Java.type("java.io.File");
var FileReader = Java.type("java.io.FileReader");
var BufferedReader = Java.type("java.io.BufferedReader");

var fc = new FileChooser;
fc.setInitialDirectory(new File("P:/"));
var f = fc.showOpenDialog(st);
var fl = new File(f);
var fr = new FileReader(fl);
var br = new BufferedReader(fr);
var blk = [];
if (fl.canRead()) {
	var lin;
	while ( (lin = br.readLine()) !== null) {
MainText.text = blk.join("\n") + "\n";