Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spotting changes to a MappedByteBuffer

John Cozens
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading large volumes of data from a file into a charting application. As the source file can be tens of MB and data for a single chart display can be several hundred KB, it makes sense to me to use a MappedByteBuffer (MBB). No problem so far.

The data from this MBB then needs to be parsed and converted into chart-friendly format. Again, no problem.

However, my chart display is intended to update in real-time as new data arrives (i.e. as new data is added to the end of the original data file from an extrenal source). So what I'd really like is to be notified whenever the MBB changes, so that I can then interrogate the change to decide whether or not to update the chart currently visible on-screen. Given that most of my work is Swing-related, I was looking for something along the lines of a MBB.addChangeListener() method or similar, but no such thing exists. I'd prefer not to have to set up a dedicated thread to monitor the MBB constantly if a cleaner solution already exists somewhere within the API. I've also looked at "listeners" in RandomAccessFile and FileChannel, both of which I use to back the MBB, but so far to no avail.

Does anyone have any smart ideas?

Thanks for your help.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic