0

I am preparing a talk introducing NIO/NIO2 for our local Java Users Group and I am trying to work out how to accomplish a particular task. The basic concept is this... Open an AsynchronousFileChannel and somehow set up a callback so that whenever new data is available on that file, the application will read the new bytes and do something with them. I know I could do this with a file watch, but that requires re-opening the file on every event, right?

Deven Phillips
  • 1,129
  • 14
  • 39
  • You are throwing two different things into one question. An `AsynchronousFileChannel` allows you to run parallel to the hardware processing the request, a watch service allows you to learn when other applications have modified a file. These two things are unrelated. – Holger Sep 16 '15 at 15:40
  • @Holger agreed. I believe that's what I said above. – Deven Phillips Sep 16 '15 at 17:29
  • You said “I am trying to work out how to accomplish a particular task”. Then you mention these two unrelated concepts, referring to the event “whenever new data is available on that file” which means entirely different things in both contexts. If you really intended to say that these two things are completely unrelated, then why didn’t you notice that you still didn’t tell which one matches your “particular task”? You could make your intention clear by simply removing the unrelated one… – Holger Sep 16 '15 at 17:37
  • @Holger either way, your comment is unhelpful at best. – Deven Phillips Sep 16 '15 at 19:24
  • You are actually standing in your own way by refusing to clarify your question. If you don’t tell us want you want to achieve, we can’t help you. And that’s not our fault. – Holger Sep 17 '15 at 07:41

0 Answers0