-2

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

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Java Bird
  • 53
  • 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
  • 22,334
  • 15
  • 80
  • 130