-
FileReader help
I'm trying the following without a lot of luck. Its being called as a ECMAScript function from an application and I keep getting an error that readFile isnt known.
I'm not sure how to actually call the FileReader to read the file in, does anyone have any tidbits based on the code below?
importPackage(Packages.java.io);
function userLookup(strFileName,username){
var nNumLines = 0; //number of lines in file
var stringToConfirm = username; //will hold text from file
var document = new java.io.FileReader(strFileName);
document.FileReader.readFile(strFileName);
nNumLines = document.FileReader.getNumLines();
for (var i=0; i<nNumLines; i++){
stringToConfirm += document.FileReader.getLine(i) + "\n";
}
alert(stringToConfirm);
}
function getLines(strFileName){
var stringDataFromFile = ""; //will hold string data in file
document.FileReader.readFile(strFileName);
stringDataFromFile += document.FileReader.getLines();
alert(stringDataFromFile);
}
-
Seems to me this is JavaScript, not Java. JavaScript and Java are completely different technologies from each other. If you want to find an answer for a JS question, better to post it in a JS forum.