Conversion of String to Int

Had some trouble with passing a string input via the command screen and changing it to an int. Im prob using the wrong code but im not sure if that is it.
import javax.swing.JFrame;
import java.util.Scanner;
public class P524Driver
public static void main ( String args[] )
     Scanner input = new Scanner(System.in);
     // Input the rows of the Diamond
     System.out.print ("Input the number of rows (Must be and oddnumber): ");
int x = input.nextInt();
     String z;
     if (x > 0) //     Determine if the value entered was valid
     while ( x % 2 == 0 )
          System.out.print( "You Input a even number try again: ");
          x = input.nextInt();
          while ( x % 2 != 0)
          System.out.print( "Input the charater: ");
          z = input.next();
          int y = Integer.parseInt(z);
{else{ System.exit(0);}
}

Ok I don't know if this is going to work with your input, but here goes. The way I declared user input was as so : BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); and the way I declared the integer value of the input was as so : int value = Integer.parseInt(console.readLine());Hope this helps!

Similar Messages

  • Please help me with my code (has conversion from string to int)

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class Test3 extends MIDlet implements CommandListener
    {   Form mForm;
        Command mCommandQuit;
        Command mCommandItem;
        TextField input,prime1,prime2,prime3,output;
        Display mDisplay;
        int i,j=0,k1,k2,p,q,b;
        //int [] current=new int [1000];
        String mstring,a="";
        String [] temp=new String [1000];
        public void startApp()
        {System.out.println("startApp");
         mForm=new Form("RSA Encryption");
         mCommandQuit=new Command("QUIT",Command.EXIT,0);
         mCommandItem=new Command("ENCRYPT",Command.ITEM,0);
         mForm.append("Enter text:\n");
         input=new TextField(null,"",100, TextField.ANY);
         mForm.append(input);
         mForm.append("Enter first prime number(p):\n");
         prime1=new TextField(null,"",100, TextField.ANY);
         mForm.append(prime1);
         mForm.append("Enter second prime number(q):\n");
         prime2=new TextField(null,"",100, TextField.ANY);
         mForm.append(prime2);
         mForm.append("Enter d:\n");
         prime3=new TextField(null,"",100, TextField.ANY);
         mForm.append(prime3);
         mForm.addCommand(mCommandQuit);
         mForm.addCommand(mCommandItem);
         mDisplay=Display.getDisplay(this);
         mDisplay.setCurrent(mForm);
         mForm.setCommandListener(this);
        public void pauseApp()
        {System.out.println("pauseApp");
        public void destroyApp(boolean unconditional)
        {System.out.println("destroyApp");
        public void commandAction(Command c, Displayable d)
        {System.out.println("commandAction");
         if(c==mCommandQuit)
            notifyDestroyed();
         else if(c==mCommandItem)
         {p = Integer.parseInt(prime1.getString());
             q = Integer.parseInt(prime2.getString());
             b = Integer.parseInt(prime3.getString());
             //breaking up of big string into ints
             mstring=input.getString();
             temp[0]="";
             for(i=1;i<mstring.length();i++)
                {if (mstring.charAt(i) == ' ')
                    {j++;
                     temp[j]="";
                 else
                    {temp[j]=temp[j]+mstring.charAt(i);
             mForm.append("\n\nThe array is:\n");
             for(i=0;i<temp.length && temp!=null;i++)
    {k1=Integer.parseInt(temp[i]); ***********************
    k2=k1;
    for(j=1;j<b;j++)
    {k1=k1*k2;
    k1=k1 %(p*q);
    k2=k1 %(p*q);
    a=a+new Character((char)k2).toString();
    output=new TextField(null,a,100, TextField.ANY);
    mForm.append(output);
    }hi
    this code basically takes an input of string like " 179 84 48 48 155 " (with spaces)
    then it creates smaller strings in an array like "179","84","48","48","155" without the spaces
    then it creates int values 179,84,48,48,155 and finally after some math functions it prints the corresponding letters.
    the problem is that it is not printing the letter because of some exceptions-->java.lang.NumberFormatException .it comes in the line where i have put stars
    could anybody please help me print the letters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    thanks for all ur help guys, but me and my team member solved it on our own. here is the new code:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class Test3 extends MIDlet implements CommandListener
    {   Form mForm;
        Command mCommandQuit;
        Command mCommandItem;
        TextField input,prime1,prime2,prime3,output;
        Display mDisplay;
        int i,j=0,l,k1,k2,p,q,n,b;
        String mstring,a = "";
        String [] temp=new String [1000];
        public void startApp()
        {System.out.println("startApp");
         mForm=new Form("RSA Encryption");
         mCommandQuit=new Command("QUIT",Command.EXIT,0);
         mCommandItem=new Command("DECRYPT",Command.ITEM,0);
         mForm.append("Enter text:\n");
         input=new TextField(null,"",100, TextField.ANY);
         mForm.append(input);
         mForm.append("Enter first prime number(p):\n");
         prime1=new TextField(null,"",100, TextField.NUMERIC);
         mForm.append(prime1);
         mForm.append("Enter second prime number(q):\n");
         prime2=new TextField(null,"",100, TextField.NUMERIC);
         mForm.append(prime2);
         mForm.append("Enter d:\n");
         prime3=new TextField(null,"",100, TextField.NUMERIC);
         mForm.append(prime3);
         mForm.addCommand(mCommandQuit);
         mForm.addCommand(mCommandItem);
         mDisplay=Display.getDisplay(this);
         mDisplay.setCurrent(mForm);
         mForm.setCommandListener(this);
        public void pauseApp()
        {System.out.println("pauseApp");
        public void destroyApp(boolean unconditional)
        {System.out.println("destroyApp");
        public void commandAction(Command c, Displayable d)
        {System.out.println("commandAction");
         if(c==mCommandQuit)
            notifyDestroyed();
         else if(c==mCommandItem)
         {p = Integer.parseInt(prime1.getString());
             q = Integer.parseInt(prime2.getString());
             b = Integer.parseInt(prime3.getString());
             n=p*q;
             //breaking up of big string into ints
             mstring=input.getString();
             temp[0]="";
             for(i=1;i<mstring.length();i++)
                {if (mstring.charAt(i) == ' ')
                    {j++;
                     temp[j]="";
                 else
                    {temp[j]=temp[j]+mstring.charAt(i);
             l=j;
             mForm.append("\n\nThe result is:\n");
             for(i=0;i<l;i++)
                {k1=Integer.valueOf(temp).intValue();
    k2=k1;
    for(j=1;j<b;j++)
    {k2=k2*k1;
    k2=k2 %n;
    k1=k2 %n;
    a=a+new Character((char)k1).toString();
    output=new TextField(null,a,100, TextField.ANY);
    mForm.append(output);

  • Conversion from String to int..NumberFormatException??

    Hey all
    I am trying to read in a file that has nothing but numbers listed one per line. I am using the bufferedReader class and reading in by line. When I check to see if the one 'string' is the same as another, it says they are the same, when really they are different. I then thought to convert the numbers to integers after reading them in, but it gives me a number format exception. My process is simple:
    1) line = in.readLine();
    2) int variable = Integer.valueOf(line).intValue();
    This gives me the damn exception. The numbers are three digits, e.g. 333, etc. Does anybody know how I can avert this problem or achieve the result I am looking for another way? All I want is to know what numbers are listed in their, without going through by hand checking. Thanks

    hi...try this..
    1.Use filereader instead of bufferedreader..OKAY
    2. OR USE...
    String str = br.readLine();
    use... int sanjeev = Integer.parseInt(str);
    3 OR...and helloooo one thing more...how u r checking that these 2 strings r same..
    get CLEAR IDEA about equals method and "=="..

  • Conversion from String to Int

    import java.io.*;
    import java.util.*;
    import java.lang.*;
    public static void main(String[] args) throws Exception{
    int Ze=0;
    String Temp = "512";
    Ze = parseInt(Temp);
    I got an error saying --->>
    cannot resolve symbol
    symbol : method parseInt(java.lang.String)
    I tried using ...Integer(Temp)
    and it gives me a similar error message.
    where Did i went wrong???

    http://java.sun.com/j2se/1.5.0/docs/api/index.html
    Bookmark that page. It's the index to the documentation of every class in Java 1.5.0. If you've got a different JDK, look on the download page and find the Documentation. Look for the API documentation in that.
    Go look up the Byte class and see. The API documentation tells every available method for every available class in the java.*, javax.*, and org.* packages. Better start getting used to using it now rather than later.

  • Problem with String to Int conversion

    Dear Friends,
    Problem with String to Int conversion
    I am having a column where most of the values are numeric. Only 4 values are non numeric.
    I have replaces those non numeric values to numeric in order to maintain the data type.
    CASE Grade.Grade  WHEN 'E4' THEN '24'  WHEN 'E3' THEN '23'  WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade  END
    This comes the result as down
    Grade
    _0_
    _1_
    _10_
    _11_
    _12_
    _13_
    _14_
    _15_
    _16_
    _17_
    _18_
    _19_
    _2_
    _20_
    _21_
    _22_
    _23_
    _24_
    _3_
    _4_
    _5_
    _6_
    _7_
    _8_
    _9_
    Refresh
    Now I want to convert this value to numeric and do some calculation
    So I changed the formula as below
    cast (CASE Grade.Grade  WHEN 'E4' THEN '24'  WHEN 'E3' THEN '23'  WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade  END as INT)
    Now I get the following error
    View Display Error
    _     Odbc driver returned an error (SQLExecDirectW)._
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    _State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1722, message: ORA-01722: invalid number at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed. (HY000)_
    SQL Issued: SELECT cast ( CASE Grade.Grade WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade END as Int) saw0 FROM "Human Capital - Manpower Costing" WHERE LENGTH(CASE Grade.Grade WHEN 'E1' THEN '20' WHEN 'E2' THEN '21' WHEN 'E3' THEN '22' WHEN 'E4' THEN '23' ELSE Grade.Grade END) > 0 ORDER BY saw_0_
    Refresh
    Could anybody help me
    Regards
    Mustafa
    Edited by: Musnet on Jun 29, 2010 5:42 AM
    Edited by: Musnet on Jun 29, 2010 6:48 AM

    Dear Kart,
    This give me another hint, Yes you are right. There was one row which returns neither blank nor any value.
    I have done the code like following and it works fine
    Thanks again for your support
    Regards
    Code: cast (CASE (CASE WHEN Length(Grade.Grade)=0 THEN '--' ELSE Grade.Grade END) WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' when '--' then '-1' ELSE Grade.Grade END as Int)

  • String to int conversion

    can n e body tell me how can i convert a String to an int

    always remember to use the try/catch block with thins that throw exceptions
    String gg;
    int in;
    try{  
    gg = "30";
       in = Integer.parseInt(gg);
    catch(NumberFormatException e){ 
      e.printStackTrace();
    }Ant

  • Problem with conversion of strings like THISStr - this_str capitalization

    Problem with conversion of strings like. THISStr -> this_str
    Can anybody pass on the reverse code. I have one, but its faulty.
    public static String convertFromPolycaps(String str) {
              Pattern pattern = Pattern.compile("\\p{Upper}+");
              Matcher matcher = pattern.matcher(str);
              StringBuffer result = new StringBuffer();
              // We do manual replacement so we can change case
              boolean notFirst = false;
              int grpP = 0, grpA = 0;
              String last = "";
              String now = "";
              while (matcher.find()) {
                   grpA = matcher.end();
                   if (notFirst) {
                        now = matcher.group().substring(0).toLowerCase();
                        if (grpA - grpP > 1) {
                             matcher.appendReplacement(result, now);
                             result =
                                  new StringBuffer(
                                       result.substring(0, (result.length() - 1))
                                            + "_"
                                            + result.substring(result.length() - 1));
                        } else {
                             matcher.appendReplacement(result, "_" + now);
                   } else {
                        matcher.appendReplacement(result, matcher.group().substring(0).toLowerCase());
                        notFirst = true;
                   grpP = matcher.end();
                   ////index++;
                   last = now;
              matcher.appendTail(result);
              System.err.println(str + " : " + result.toString());
              return result.toString();
         }succesfully converts :
    AccountNmnc : account_nmnc
    CustNameJ : cust_name_j
    Resume : resume
    BeneBrCode : bene_br_code
    ApprovedPerson : approved_person
    but fails for:
    GLCode : glcode
    VISHALErrCode : vishalerr_code
    GHASUNNAcNo : ghasunnac_no

    Can anybody pass on the reverse code. I have one, but
    its faulty.Post it, I'm sure we can fix it...

  • String to Int and Int to String

    How can I convert a string to Int & and an Int to String ?
    Say I've
    String abc="234"
    and I want the "int" value of "abc", how do I do it ?
    Pl. help.

    String.valueOf(int) takes an int and returns a string.
    Integer.parseInt(str) takes a string, returns an int.
    For all the others long, double, hex etc. RTFM :)

  • Conversion from string "20041023 " to type 'Date' is not valid.

    Hi ,
       I have a table with one of the column(EmpHiredate) datatype is char(10). It has value like "20141023". I need to display this value as date format(dd/mm/yyyy) in report. 
    Following methods i tried in textbox expression but no luck.
    =Format(Fields!EmpHireDate.Value,"dd/MM/yyyy")
    =Cdate(Fields!EmpHireDate.Value)
    Error:
    [rsRuntimeErrorInExpression] The Value expression for the textrun ‘EmpHireDate.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "20041023  " to type 'Date' is not valid.
    Is it possible to convert string to date using SSRS textbox expression ? Can anyone help me with the solution.
    Thanks,
    Kittu

    Hi Jmcmullen,
         Found one more issue on the same. I have one value like "00000000" for the column(EmpHiredate)
    , when i use above expression values(ex:"20141023")
    are displaying in dd/MM/yyyy format in report except value like "00000000" and giving following error:
    [rsRuntimeErrorInExpression] The Value expression for the textrun ‘EmpHireDate.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "0000/00/00" to type 'Date' is not valid.
    Even i tried to pass its original value("00000000") as below but no luck.
    =IIF(Fields!EmpHireDate.Value = "00000000","00000000",Format(CDATE(MID(Fields!EmpHireDate.Value,1,4) + "/" + MID(Fields!EmpHireDate.Value,5,2) + "/" + MID(Fields!EmpHireDate.Value,7,2)),"dd/MM/yyyy"))
    Also tried this:
    =IIF(Fields!EmpHireDate.Value = "00000000","2000/10/21",Format(CDATE(MID(Fields!EmpHireDate.Value,1,4) + "/" + MID(Fields!EmpHireDate.Value,5,2) + "/" + MID(Fields!EmpHireDate.Value,7,2)),"dd/MM/yyyy"))
    Please Suggest. 
    Thanks ,
    Kittu

  • Conversion of string into XML object

    Hi
    I am having some problems with conversion of string (containing XML data) into Flex XML object and binding it later to UI elements to output/maintain this data.
    Binding of XML structure to UI elements works perfectly fine if I will do following:
    1)      Hardcode XML object within Flex file
    2)      Read xml file from repository (xml file inside the Flex project)
    3)      Use HTTP request to retrieve XML data
    Unfortunately none of the above scenarios suits my solution.
    I am developing a prototype application for processing Flex forms inside SAP system. I have decided to make data bindings using XML structure stored in Data Base. When rendering form inside web browser based application I am retrieving corresponding XML schema (empty for new forms and populated for saved forms) and pass it to Flex form as a string type import parameter. Data is being passed correctly (I can display it on TextArea control for instance) but after conversion to XML and binding to DataGrid I am not getting any results.
    I am converting string (containing XML) to XML object in following way:
    Private var xml_obj:XML = new XML(string_xml );
    I am catching any potential errors but conversion is going well. After conversion I am not getting any results after binding it to DataGrid control and I am not able to access any of the nodes using AS code either. At the same time variable xml_obj is not empty (not null).
    Any help would be much appreciated.
    Regards
    Michael

    David
    First of all sorry for not stating it clearly but I am using Flex 3 for this development (at the moment it is the only choice when embedding Flex objects inside SAP applications).
    You must have missed the bit where I am describing how this XML data finds its way inside Flex. I am passing it to Flex as String type parameter during rendering (directly from DB where it is stored).
    Now, following code works perfect (XML is embedded inside Flex project):
                    <mx:XML id="form_data" source="../assets/example_xml_data.xml"/>
                    <mx:Script>
                                    <![CDATA[
                                                    import mx.collections.XMLListCollection;
                                                    import mx.controls.Alert;
                                                    [Bindable]
                                                    public var XML_list:XMLListCollection;
                                                    private function setParameters():void
                                                                   XML_list = new XMLListCollection(form_data.*);             
                                    ]]>
                    </mx:Script>
                    <mx:DataGrid id="myDataGrid" dataProvider="{XML_list}">
                                    <mx:columns>
                                                    <mx:DataGridColumn dataField="COMMON" headerText="Popular name"/>
                                                    <mx:DataGridColumn dataField="BOTANICAL" headerText="Botanical name"/>
                                                    <mx:DataGridColumn dataField="ZONE" headerText="Zone"/>
                                                    <mx:DataGridColumn dataField="LIGHT" headerText="Light"/>                                                                                                                                               
                                                    <mx:DataGridColumn dataField="PRICE" headerText="Price"/>                                               
                                                    <mx:DataGridColumn dataField="AVAILABILITY" headerText="Availability"/>                                    
                                    </mx:columns>               
                    </mx:DataGrid>
    But following code does not work (XML passed to Flex form as String input parameter):
    import sap.FlashIsland;
    import mx.controls.Alert;
    import mx.collections.XMLListCollection;
    [Bindable]
    public var xml_data:String;
    private var form_data:XML;
    [Bindable]
    private var XML_list:XMLListCollection;
    private function initApp():void
                    FlashIsland.register(this);
    private function setParameters():void
                    try
                                    form_data=new XML(xml_data);
                    catch (error:Error)
                                    Alert.show(error.toString());
                      XML_list = new XMLListCollection(form_data.*);           
    XML string does find its way inside Flex form. I can display content of variable xml_data in TextArea and all looks fine. Conversion to XML (variable form_data) goes well (no error)
    Please helpJ
    Regards
    Michael

  • Conversion of String to Bytes and Length Calculation

    hi,
    How can I convert
    String to Bytes
    Bytes to String
    int to Bytes
    Bytes to int
    & int to String
    And I have to calculate the Length in Bytes of a String and int.
    Thanks

    double d = Double.parseDouble(new String(byteDouble)); Java doesn't seem to accept to convert byteDouble to a String...
    Exception in thread "main" java.lang.NumberFormatException: For input string: "[B@1d9fd51"
      at java.lang.NumberFormatException.forInputString (NumberFormatException.java:48)
      at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1213)

  • How to read a C structure with string and int with a java server using sock

    I ve made a C agent returning some information and I want to get them with my java server. I ve settled communication with connected socket but I m only able to read strings.
    I want to know how can I read strings and int with the same stream because they are sent at the same time:
    C pgm sent structure :
    char* chaine1;
    char* chaine2;
    int nb1;
    int nb2;
    I want to read this with my java stream I know readline methode to get the first two string but after two readline how should I do to get the two int values ?
    Any idea would be a good help...
    thanks.
    Nicolas (France)

    Does the server sent the ints in little endian or big endian format?
    The class java.io.DataInputStream (with the method readInt()) can be used to read ints as binary from the stream - see if you can use it.

  • "Conversion to String failed"  When attempting to call rs.getString()

    Hello All,
    I'm getting a "Conversion to String failed" exception being thrown from oracle jdbc when I attempting to call the rs.getString(1) method on a column type of DATE.
    During investigations we've found the following:
    1. The query is fine, and is performing a "select * from table".
    2. I see this problem when using 9i database (v 9.2.0.7) with 9i jdbc drivers (v9.2.0.7).
    3. Strangely enough, if I use 10g jdbc drivers with the 9i database this problem goes away, and naturally I don't see this problem at all using a 10g driver working against a 10g database.
    4. Grabbing the DATE value using the getDate() instead of getString() API works just fine in 9i.
    5. The 9i rs.getString() API call will work with some date values in the database and not with others.
    6. The data placed into the DATE column in question could have been placed there using different driver type from the 9i.
    So, the 9i getString() API seems to be a problem.
    At this point, based upon points 5 and 6 above, I'm thinking there is a bug in the oracle 9i jdbc drivers that is unable to convert DATE type data using the getString() API if the data was initially placed into the database using a different driver type. But, this would mean that the format of the data in the database would be different depending upon the means of getting the data there in the first place (which doesn't make much sense).
    Here is the pertinent Stack Trace:
    java.sql.SQLException: Conversion to String failed
    at oracle.sql.Datum.stringValue(Datum.java:173)
    at oracle.jdbc.driver.ScrollableResultSet.getString(ScrollableResultSet.java:684)
    at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1549)
    at com.revenuesolutionsinc.dali.sql.DALResultSet.getString(DALResultSet.java:325)
    Any help on this matter would be greatly appreciated.
    Thanks,
    Doug Newcomb

    Doug,
    Pardon me for stating the obvious, but is there a
    reason why you cannot use method "getDate()" instead
    of method "getString()"?
    For your information, you can report bugs via the
    MetaLink
    Web site.
    Good Luck,
    Avi.Thanks for the reply Avi,
    The main reason is that we've got mountains of code that would need to be refactored. Also, the getString() method worked fine for over a year.
    So we are looking towards finding out why this is happening before making the decision to refactor.
    I will be placing a TAR with Oracle on Monday, but I thought I'd try to find out if anyone else has run into a similar problem.

  • Regional settings impact JavaScript Number conversion to String in applet

    Environment:
    XP, IE6 and IE7, JDK 1.6.0_13,1.6.0_10,1.6.0_7, Apache
    Hi,
    We recently converted our application from the MS JVM to Sun JVM 1.6 and have since had numerous problems with a user's regional setting impacting the application's behaviour.
    The application is using an applet, passing JavaScript Number values to an Applet where the input argument in the Java function is declared as a String.
    We have users with various regional settings, most don't impact the application, but we have found problems when the regional settings are set to "French (France)" or "German (Germany)".
    With "French (France)" JavaScript Number values >=10000000 get truncated to a Java String value of just the first character.e.g. 10000000 is converted to "1", 200000000 is converted to "2".
    With "German (Germany)" a trailing "0" is added to the converted String, and for values >=10000000 we get the String value with an additional 6 "0"s and then 2 additional "0"s as the input Number value is increments by each power of 10.
    A simple example follows.
    Any help understanding why this is happening and any coding solution would be appreciated.
    The default number format for the various regional settings seems to be impacting the implicit conversion to String in LiveConnect.
    We can re-code to convert the Number value to a String in the JavaScript before calling the applet, but this involves significant re-coding of the application.
    We also have a workaround to verify that navigator.userLanguage returns one of the list of supported languages and exit the application if the language is unsupported.
    Thanks
    Rob
    Example output for test:
    OK
    English (United States)
    Regional Settings Number format sample: 123,456,789.00
    lang=en-us,javascript Number=1,Applet Java String value =(1)
    lang=en-us,javascript Number=11,Applet Java String value =(11)
    lang=en-us,javascript Number=111,Applet Java String value =(111)
    lang=en-us,javascript Number=1111,Applet Java String value =(1111)
    lang=en-us,javascript Number=11111,Applet Java String value =(11111)
    lang=en-us,javascript Number=111111,Applet Java String value =(111111)
    lang=en-us,javascript Number=1111111,Applet Java String value =(1111111)
    lang=en-us,javascript Number=11111111,Applet Java String value =(11111111)
    lang=en-us,javascript Number=111111111,Applet Java String value =(111111111)
    lang=en-us,javascript Number=1111111111,Applet Java String value =(1111111111)
    lang=en-us,javascript Number=11111111111,Applet Java String value =(11111111111)
    NOT OK >=10000000
    French (France)
    Regional Settings Number format sample: 123 456 789,00
    lang=fr,javascript Number=1,Applet Java String value =(1)
    lang=fr,javascript Number=11,Applet Java String value =(11)
    lang=fr,javascript Number=111,Applet Java String value =(111)
    lang=fr,javascript Number=1111,Applet Java String value =(1111)
    lang=fr,javascript Number=11111,Applet Java String value =(11111)
    lang=fr,javascript Number=111111,Applet Java String value =(111111)
    lang=fr,javascript Number=1111111,Applet Java String value =(1111111)
    lang=fr,javascript Number=11111111,Applet Java String value =(1)
    lang=fr,javascript Number=111111111,Applet Java String value =(1)
    lang=fr,javascript Number=1111111111,Applet Java String value =(1)
    lang=fr,javascript Number=11111111111,Applet Java String value =(1)
    NOT OK
    German (Germany)
    Regional Settings Number format sample: 123.456.789,00
    lang=de,javascript Number=1,Applet Java String value =(10)
    lang=de,javascript Number=11,Applet Java String value =(110)
    lang=de,javascript Number=111,Applet Java String value =(1110)
    lang=de,javascript Number=1111,Applet Java String value =(11110)
    lang=de,javascript Number=11111,Applet Java String value =(111110)
    lang=de,javascript Number=111111,Applet Java String value =(1111110)
    lang=de,javascript Number=1111111,Applet Java String value =(11111110)
    lang=de,javascript Number=11111111,Applet Java String value =(111111110000000)
    lang=de,javascript Number=111111111,Applet Java String value =(11111111100000000)
    lang=de,javascript Number=1111111111,Applet Java String value =(1111111111000000000)
    lang=de,javascript Number=11111111111,Applet Java String value =(1.1111111111E20)
    Example code:
    Test1.java
    import java.applet.Applet;
    public class Test1 extends Applet {
    public void init() {
    public String stringTest(String str) {
    String out = "Applet Java String value =(" + str + ")";
    return(out);
    index.html
    <html>
    <body>
    <APPLET CODE="Test1.class" NAME="test1" WIDTH="0" HEIGHT="0">
    <PARAM NAME="scriptable" Number="true">
    </APPLET>
    <script type="text/javascript">
    var x;
    document.write("<BR>")
    x = Number("1");
    document.write("lang="+navigator.userLanguage +",javascript Number=" x "," + document.test1.stringTest(x)+"<BR>");
    document.write("<BR>copy/paste the above 2 lines of code, adding an additional '1'<BR>");
    </script>
    </body>
    </html>
    </html>

    I have found a workaround by setting the locale in the applet to a locale that does perform implicit Number to String conversion correctly.
    e.g.
    public void init() {
    try {
    Locale.setDefault(Locale.US);
    } catch (Exception e) {
    System.err.println("Failed to set Locale, Caught Exception: " + e.getMessage());
    and adding this line to the java.policy to prevent "access denied (java.util.PropertyPermission user.language write)" errors.
    permission java.util.PropertyPermission "user.language", "read, write";

  • How to convert String to int in JSP?

    Hi,
    I set a session attribute in Servlet and want use it in JSP, How can I convert it to int or Integer?
    the line in my code doesn't work:
    int quantity=(int)session.getAttribute("vehiclequantity") ;
    Thanks in advance.
    Wolf
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    <HTML>
    <HEAD>
    <TITLE>Using the for Statement</TITLE>
    </HEAD>
    <BODY>
    <H1>Using the for Statement</H1>
    <%=session.getAttribute("vehiclequantity") %>;
    <%
    int loopIndex;
    int quantity=(int)session.getAttribute("vehiclequantity") ;
    out.println(quantity);
    for (loopIndex = 1; loopIndex <=2; loopIndex++) {
    out.println("This is iteration number "
    + loopIndex + "<BR>");
    %>
    </BODY>
    </HTML>

    Learning how to read errors and understand them will help you solve your problems quicker by yourself... So lets take a look at the error and classes involved...
    The error says:
    "Cannor Resolve Symbol: method valueOf(java.lang.Object) in the class java.lang.Integer" and gives you line line where the error occurs: Integer quantity = Integer.valueOf(session.getAttribute("vehiclequantity"));
    Now, if we look at the API for the Integer we notice that are are only two valueOf methods: valueOf(java.lang.String s) and valueOf(java.lang.String s, int radix). Not valueOf(java.lang.Object) method.
    Now we look at the getAttribute(java.lang.String name) method of HttpSession we see that the method returns a java.lang.Object. Now, you know you put a java.lang.String into that attribute, but the get method returns an Object. This is because you could have put any object in there, an Integer, a String, or some other class instance. But you know it is a String, so you can cast the returned value to a String, so that you will be calling the valueOf(java.lang.String s) method of Integer with the Object returned from the HtttpSession's getAttribute(java.lang.String name) method:
    Integer quantity = Integer.valueOf((String)session.getAttribute("vehiclequantity"));

Maybe you are looking for

  • Can't see scanner...

    I have a Canoscan 8800f that I use through Photostudio or MP Navigator Ex. I recently installed a new Canon MP620 printer. Now when I open Photostudo or MP Navigator Ex it is seeing the printer as the default devise, and I can't even find or select t

  • Film Presets

    I've packaged some basic Premiere Pro presets for everyone.  It includes the old Film Fades from a ways back (the built-in Adobe version of the Film Fade doesn't really emulate a genuine film fade all that well), as well as some Letterboxing presets

  • Which Backup server version is required for Sybase cumulative dump/load

    Hello, To perform cumulative dump and load (supported from ASE 15.7 SP100 and up) with 3rd party API, what backup server version is needed? We use backup server API version 2.1, and sybackup.h does not have any definition for cumulative dump. This he

  • Recognizing individual media files not the Folders

    I am using the Trial Version of FCPX. Yesterday it recognized the FOLDERS in Finder and imported using them for Keywords. Today, it only sees individual media files in the top level MOVIES folder. There are many folders inside my MOVIES folder, but i

  • Browser-based authentication on E71

    Hi, I would appreciate any advice on how to enable browser-based authentication on my Nokia E71? I am a frequent traveller and cannot access any websites on the hotel provided wifi services. Thanks!