B4J Question Is there a better way?

Bruce Axtens

Active Member
Licensed User
Longtime 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:
B4X:
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.setTitle("1-Test.js");
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) {
		blk.push(lin);
	}
}
MainText.text = blk.join("\n") + "\n";
 
Top