Solved

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

Posted on 2016-10-20
3
71 Views
Last Modified: 2016-10-21
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
0
Comment
Question by:sidwelle
3 Comments
 
LVL 52

Accepted Solution

by:
Julian Hansen earned 250 total points
ID: 41853426
Can we see some source code?
0
 
LVL 16

Assisted Solution

by:krakatoa
krakatoa earned 250 total points
ID: 41853610
In mainstream Java, codePointAt(int index) in the String class returns an int, and charAt(int index) returns a char.
0
 

Author Closing Comment

by:sidwelle
ID: 41854247
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now