Note that there are some explanatory texts on larger screens.

plurals
  1. POLong.parseLong error when parsing a string from a SAXparser class (Java)
    primarykey
    data
    text
    <p>I have a problem but I don't know how to solve it: I need to get a Long number from a String (I get this string in a SAXparser class I wrote to get some fields from an XML file).</p> <p>Here you are the problematic code:</p> <pre><code>if (bprice) { String price = new String(ch, start, length); System.out.println("Product price: " + price); bprice = false; if (price.equalsIgnoreCase("0")) product.price = null; else product.price = Long.parseLong(price); } </code></pre> <p>(<strong>product</strong> is an instance from an object where I store all the product information. I got the error in the last line)</p> <p>I debugged it and I got this:</p> <blockquote> <blockquote> <p>Exception occurred in target VM: For input string: "1.04" java.lang.NumberFormatException: For input string: "1.04" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Long.parseLong(Long.java:419) at java.lang.Long.parseLong(Long.java:468) at parsers.LectorXML.characters(LectorXML.java:325) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.characters(AbstractSAXParser.java:538) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:464) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) at parsers.LectorXML.leer(LectorXML.java:71) at parsers.LeerXML.main(LeerXML.java:20) &lt;</p> </blockquote> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload