Results 1 to 2 of 2

Thread: FileReader help

  1. #1
    emp
    emp is offline Member
    Join Date
    Apr 2009
    Posts
    5
    Rep Power
    0

    Default 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);


    }

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    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

  1. Replies: 5
    Last Post: 02-02-2010, 09:06 AM
  2. add FileReader to GUI
    By VinTiger in forum New To Java
    Replies: 8
    Last Post: 05-11-2009, 12:23 AM
  3. FileReader / Buffered Reader
    By sepaht in forum New To Java
    Replies: 9
    Last Post: 07-10-2008, 08:05 PM
  4. Help with filereader in java
    By zoe in forum Advanced Java
    Replies: 2
    Last Post: 07-26-2007, 09:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •