Reputation: 1
I have an output stream whose definition is define stream outStream (deviceID string, val int).
In the 'receive' method of its callback, I want to do some processing with the val(of type int). Is there any method to retrieve this integer value from the Event object?
I tried to retrieve it using "events[i].getData().toString()", but the string returned is "[Ljava.lang.Object;@c55cfc" and i can't make any sense of it. (Here, 'events' is the array of 'Events' passed in to the 'receive' method of the callback)
Thanks in advance for any assistance.
Upvotes: 0
Views: 81
Reputation: 1654
getData()
method of Event
class returns an Object[]
. That means, you'll be calling toString()
on an Object[]
. In Java, that'll print the class name + hashcode of the object (Ljava.lang.Object;@c55cfc
) (refer to this for more info). So, if you need to get the values instead, simply iterate through the Object[]
returned by getData()
method. (i.e events[i].getData()[j]
)
Upvotes: 1