Error while converting string to int

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
su2
Reply | Threaded
Open this post in threaded view
|

Error while converting string to int

su2
Hello Friends,

I have a java function, where I have a String - which has numbers stored as string.

When I "return" the string as a String, it prints perfectly fine. But I need to do some math-data manipulation with those string numbers.

When I try to convert the string into int (int a = Integer.parseInt(myString);), it gives me following error in log file

---------------------------------------------------------------------------
BSH Evaluation error.
Exception: bsh.TargetError
Message: Sourced file: inline evaluation of: ``com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal(delega . . . '' : Method Invocation com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal
---- stack trace ---------------------------------------------------------------
Sourced file: inline evaluation of: ``com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal(delega . . . '' : Method Invocation com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal : at Line: 1 : in file: inline evaluation of: ``com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal(delega . . . '' : com .opensourcestrategies .financials .reports .ReportHelper .getOrderSubTotal ( delegator , OTCMOrderNo )
Target exception: java.lang.IndexOutOfBoundsException: index: 0 for list of size: 0
bsh.BSHMethodInvocation.eval(Unknown Source)
bsh.BSHPrimaryExpression.eval(Unknown Source)
bsh.BSHPrimaryExpression.eval(Unknown Source)
bsh.Interpreter.evalParsedScript(Unknown Source)
bsh.Interpreter.eval(Unknown Source)
bsh.Interpreter.eval(Unknown Source)
bsh.Interpreter.eval(Unknown Source)
org.ofbiz.base.util.BshUtil.eval(BshUtil.java:77)
---------------------------------------------------------------------------

I was not able to understand the error.

I really appreciate the help.

Thank you in advance.
su-
Reply | Threaded
Open this post in threaded view
|

Re: Error while converting string to int

Chirag Manocha-2
Hi Shuchi,
This not seems to be the error of parsing. Look at this again :-

Target exception: java.lang.IndexOutOfBoundsException: index: 0 for list of
size: 0

It shows that you accessing first index of any arraylist of size 0.
Also I would like to confirm u have myString as a array of String or a
single String object.

(I have a String - which has _*numbers*_ stored)


Please use log messages to trace where the exact problem is coming and
post it again.

Regards
--
Chirag Manocha
HotWax Media Pvt. Ltd.
Website :- www.hotwaxmedia.com
Contact :- +91-98263-19099



su2 wrote:

> Hello Friends,
>
> I have a java function, where I have a String - which has numbers stored as
> string.
>
> When I "return" the string as a String, it prints perfectly fine. But I need
> to do some math-data manipulation with those string numbers.
>
> When I try to convert the string into int (int a =
> Integer.parseInt(myString);), it gives me following error in log file
>
> ---------------------------------------------------------------------------
> BSH Evaluation error.
> Exception: bsh.TargetError
> Message: Sourced file: inline evaluation of:
> ``com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal(delega
> . . . '' : Method Invocation
> com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal
> ---- stack trace
> ---------------------------------------------------------------
> Sourced file: inline evaluation of:
> ``com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal(delega
> . . . '' : Method Invocation
> com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal :
> at Line: 1 : in file: inline evaluation of:
> ``com.opensourcestrategies.financials.reports.ReportHelper.getOrderSubTotal(delega
> . . . '' : com .opensourcestrategies .financials .reports .ReportHelper
> .getOrderSubTotal ( delegator , OTCMOrderNo )
> Target exception: java.lang.IndexOutOfBoundsException: index: 0 for list of
> size: 0
> bsh.BSHMethodInvocation.eval(Unknown Source)
> bsh.BSHPrimaryExpression.eval(Unknown Source)
> bsh.BSHPrimaryExpression.eval(Unknown Source)
> bsh.Interpreter.evalParsedScript(Unknown Source)
> bsh.Interpreter.eval(Unknown Source)
> bsh.Interpreter.eval(Unknown Source)
> bsh.Interpreter.eval(Unknown Source)
> org.ofbiz.base.util.BshUtil.eval(BshUtil.java:77)
> ---------------------------------------------------------------------------
>
> I was not able to understand the error.
>
> I really appreciate the help.
>
> Thank you in advance.
> su-
>
>