rhino java, javascript, converting asc code to character value, but the compiler keeps complaining that "charCodeAt" is not found !

Trying to read a file in JavaScript by referencing the java libraries directly, but it returns an integer for each character.

I need to convert the integer to a char value, but the compiler states that "charCodeAt(..." is not found in the String object.

Any help is appreciated.

or an easier way of just reading the text of a file ...

Thanks
sidwelleAsked:
Who is Participating?
 
Julian HansenConnect With a Mentor Commented:
Can we see some source code?
0
 
krakatoaConnect With a Mentor Commented:
In mainstream Java, codePointAt(int index) in the String class returns an int, and charAt(int index) returns a char.
0
 
sidwelleAuthor Commented:
Thanks for answering, Got it to work. I am working w/an undocumented version of Java inside of another product, so I don't have any documentation or any examples, but I get it to work.  Once I played around long enough with the definitions:

            var reader = new java.io.FileReader(file);      
            var sb = new java.lang.StringBuilder;
      
             while ((c = reader.read()) != -1)
             {
                   sb.append(String.fromCharCode(c));
            }
      
            if (reader != null) {
                  reader.close();
            }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.