I am trying to get the contents of tags into variables in my java Sax parser. However, the Characters method only returns Char arrays. Is there anyway to get the Char array into an Int???
public void characters(char ch[], int start, int
length) {if(this.in_total_results) { // my INT varialble would be nice here! }}
Can anyone help at all?
Kind regards,
Andy
To be really correct, you would need to accumulate the value passed in characters, as it may be called more than once per tag.
This can notably happen if you have entities in the text. A tag such as
<a>123</a>is equivalent to<a>123</a>(49,50,51 are illustrative, but I think these are the right codes for 1,2,3)So here is an excerpt taken from this question:
To convert from
StringBufferto int, just usenew Integer( curCharValue.toString() ). Note that there are other methods to convert fromStringtoIntegerorint, as pointed out in the comment.