java.lang.NumberFormatException: For input string: "9813023219" -


i'm using serial event pass rfid tags read arduino processing. in serial event parsing , converting variable integer. working part, 1 rfid card keeps throwing error.

void serialevent(serial thisport) {   string instring = thisport.readstring();   if(instring != null)   {     serial connect1 = (serial) connections.get(0);       if(thisport == connect1 )       {         chair chair = (chair) chairs.get(0);         if(instring.contains("uid value:"))         {           int p2 = instring.indexof(":");           string pstring = instring.substring(p2+1);            string pstring2 = pstring.substring (0,10);           //println(pstring2);           pstring2.trim();            println("string length: " + pstring2.length());            chair.setrfid(pstring2);           println(pstring2);         }        }   } }  void setrfid(string r)   {        try{        this.rfid = integer.parseint(r);      }      catch (exception e) {       e.printstacktrace();      }       //set position of person chair      (person person : people)        {           //println(this.rfid != chair.rfid);         //println(this.rfid + "," +  "person: " + person.id + "," + person.rfid);         if(this.rfid == person.rfid)         {           person.setpos(this.pos);           this.personid = person.id;         }      }   } 

the try-catch not working, , line causing problem this.rfid = integer.parseint(r);. thought might malformed string strings seems ok. here results of checking string consistency: string length: 10 1811524219 string length: 10 1942302231 string length: 10 1010368230 string length: 10 9813023219

9813023219 invalid integer greater integer.max_value, 2147483647. use long instead, who's max_value 9223372036854775807.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -