0

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.

  • Possible duplicate of [java: what is this: \[Ljava.lang.Object;?](http://stackoverflow.com/questions/3442090/java-what-is-this-ljava-lang-object) – Grainier Feb 12 '17 at 12:46

1 Answers1

1

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])

Community
  • 1
  • 1
Grainier
  • 1,634
  • 2
  • 17
  • 30