This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

File access from javascript in code composer sutdio

Hello,

I run a javascript from the scritping console using the command LoadJSFile.

I would like to read a file from this scripts. Is there any way to do this?

Thank you

Laurent Olive

  • I found it by myself:

    try{
        //
        var fstream = new FileInputStream("C:\\test.txt");
        // Get the object of DataInputStream
        var dis = new DataInputStream(fstream);
        var br = new BufferedReader(new InputStreamReader(dis));
        var strLine;
        //Read File Line By Line
        while ((strLine = br.readLine()) != null) {
            // Print the content on the console
            print (strLine);
        }
        //Close the input stream
        dis.close();
    }
        catch (e){//Catch exception if any
        print("File read error");
    }