-2

Can we create a Java stream with an infinite source of data (e.g. Health signals)?

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
Java Bird
  • 55
  • 6

1 Answers1

2

Yes.

Of course, limiting the size would cause the stream to be finite.

With, for example, Stream.generate(() -> "tick") you have an infinite stream.

However, the actual implementation heavily depends on the shape of the source. If, for instance, for heart beats, I expect the stream coming from some external device, so then you'll need to setup the transmission as well.

MC Emperor
  • 20,870
  • 14
  • 76
  • 119