Results 1 to 2 of 2
Thread: FileReader help
- 07-28-2009, 03:10 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 5
- Rep Power
- 0
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);
}
- 07-28-2009, 04:41 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
Similar Threads
-
FileReader Vs FileInputStream and same goes to output
By unhurt in forum New To JavaReplies: 5Last Post: 02-02-2010, 09:06 AM -
add FileReader to GUI
By VinTiger in forum New To JavaReplies: 8Last Post: 05-11-2009, 12:23 AM -
FileReader / Buffered Reader
By sepaht in forum New To JavaReplies: 9Last Post: 07-10-2008, 08:05 PM -
Help with filereader in java
By zoe in forum Advanced JavaReplies: 2Last Post: 07-26-2007, 09:55 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks